-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
pubProvidedIdSystem.js
61 lines (53 loc) · 1.63 KB
/
pubProvidedIdSystem.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* This module adds Publisher Provided ids support to the User ID module
* The {@link module:modules/userId} module is required.
* @module modules/pubProvidedSystem
* @requires module:modules/userId
*/
import {submodule} from '../src/hook.js';
import { logInfo, isArray } from '../src/utils.js';
import {VENDORLESS_GVLID} from '../src/consentHandler.js';
/**
* @typedef {import('../modules/userId/index.js').Submodule} Submodule
* @typedef {import('../modules/userId/index.js').SubmoduleConfig} SubmoduleConfig
*/
const MODULE_NAME = 'pubProvidedId';
/** @type {Submodule} */
export const pubProvidedIdSubmodule = {
/**
* used to link submodule with config
* @type {string}
*/
name: MODULE_NAME,
gvlid: VENDORLESS_GVLID,
/**
* decode the stored id value for passing to bid request
* @function
* @param {string} value
* @returns {{pubProvidedId: Array}} or undefined if value doesn't exists
*/
decode(value) {
const res = value ? {pubProvidedId: value} : undefined;
logInfo('PubProvidedId: Decoded value ' + JSON.stringify(res));
return res;
},
/**
* performs action to obtain id and return a value.
* @function
* @param {SubmoduleConfig} [config]
* @returns {{id: Array}}
*/
getId(config) {
const configParams = (config && config.params) || {};
let res = [];
if (isArray(configParams.eids)) {
res = res.concat(configParams.eids);
}
if (typeof configParams.eidsFunction === 'function') {
res = res.concat(configParams.eidsFunction());
}
return {id: res};
}
};
// Register submodule for userId
submodule('userId', pubProvidedIdSubmodule);