forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathceeIdSystem.js
63 lines (54 loc) · 1.78 KB
/
ceeIdSystem.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
62
63
/**
* This module adds ceeId to the User ID module
* The {@link module:modules/userId} module is required
* @module modules/ceeId
* @requires module:modules/userId
*/
import { MODULE_TYPE_UID } from '../src/activities/modules.js';
import { getStorageManager } from '../src/storageManager.js';
import { submodule } from '../src/hook.js';
import {domainOverrideToRootDomain} from '../libraries/domainOverrideToRootDomain/index.js';
/**
* @typedef {import('../modules/userId/index.js').Submodule} Submodule
* @typedef {import('../modules/userId/index.js').IdResponse} IdResponse
*/
const MODULE_NAME = 'ceeId';
export const storage = getStorageManager({ moduleName: MODULE_NAME, moduleType: MODULE_TYPE_UID });
/**
* Reads the ID token from local storage or cookies.
* @returns {string|undefined} The ID token, or undefined if not found.
*/
export const readId = tokenName => storage.getDataFromLocalStorage(tokenName) || storage.getCookie(tokenName);
/** @type {Submodule} */
export const ceeIdSubmodule = {
name: MODULE_NAME,
gvlid: 676,
/**
* decode the stored id value for passing to bid requests
* @function decode
* @param {string} value
* @returns {(Object|undefined)}
*/
decode(value) {
return typeof value === 'string' ? { 'ceeId': value } : undefined;
},
/**
* performs action to obtain id and return a value
* @function
* @returns {(IdResponse|undefined)}
*/
getId(config) {
const { params = {} } = config;
const { tokenName, value } = params
const ceeIdToken = value || readId(tokenName);
return ceeIdToken ? { id: ceeIdToken } : undefined;
},
domainOverride: domainOverrideToRootDomain(storage, MODULE_NAME),
eids: {
'ceeId': {
source: 'ceeid.eu',
atype: 1
},
},
};
submodule('userId', ceeIdSubmodule);