-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merkleId Identity submodule submission (#5577)
* Create merkleIdSystem.js * Update userId_example.html * Update eids.md * Update userId_spec.js * Update eids.md fix to merkleinc.com * fix string break in gdpr applies warning * Update merkleIdSystem.js add consentData as param to getId * Update merkleIdSystem.js remove useless conditional part * Update userId_spec.js fix test strings to match * Update merkleIdSystem.js fixes decode function * Update merkleIdSystem.js change back decode * Update userId_spec.js fix set cookie format * Update userId_spec.js fix space before value * Update eids_spec.js * Update eids_spec.js fix spacing issue * Update merkleIdSystem.js fix decode again * Update merkleIdSystem.js typo * Update merkleIdSystem.js * Update merkleIdSystem.js * Update merkleIdSystem.js * Update .submodules.json * Update eids.js * Update eids_spec.js * Update eids.js
- Loading branch information
1 parent
2b05803
commit 3d4e25d
Showing
7 changed files
with
153 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/** | ||
* This module adds merkleId to the User ID module | ||
* The {@link module:modules/userId} module is required | ||
* @module modules/merkleIdSystem | ||
* @requires module:modules/userId | ||
*/ | ||
|
||
import * as utils from '../src/utils.js' | ||
import {ajax} from '../src/ajax.js'; | ||
import {submodule} from '../src/hook.js' | ||
|
||
const MODULE_NAME = 'merkleId'; | ||
|
||
/** @type {Submodule} */ | ||
export const merkleIdSubmodule = { | ||
/** | ||
* 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(value) { | ||
const id = (value && value.ppid && typeof value.ppid.id === 'string') ? value.ppid.id : undefined; | ||
return id ? { 'merkleId': id } : undefined; | ||
}, | ||
/** | ||
* performs action to obtain id and return a value in the callback's response argument | ||
* @function | ||
* @param {SubmoduleParams} [configParams] | ||
* @param {ConsentData} [consentData] | ||
* @returns {IdResponse|undefined} | ||
*/ | ||
getId(configParams, consentData) { | ||
if (!configParams || typeof configParams.pubid !== 'string') { | ||
utils.logError('User ID - merkleId submodule requires a valid pubid to be defined'); | ||
return; | ||
} | ||
|
||
if (typeof configParams.ptk !== 'string') { | ||
utils.logError('User ID - merkleId submodule requires a valid ptk string to be defined'); | ||
return; | ||
} | ||
|
||
if (consentData && typeof consentData.gdprApplies === 'boolean' && consentData.gdprApplies) { | ||
utils.logError('User ID - merkleId submodule does not currently handle consent strings'); | ||
return; | ||
} | ||
|
||
const url = `https://mid.rkdms.com/idsv2?ptk=${configParams.ptk}&pubid=${configParams.pubid}`; | ||
|
||
const resp = function (callback) { | ||
const callbacks = { | ||
success: response => { | ||
let responseObj; | ||
if (response) { | ||
try { | ||
responseObj = JSON.parse(response); | ||
} catch (error) { | ||
utils.logError(error); | ||
} | ||
} | ||
callback(responseObj); | ||
}, | ||
error: error => { | ||
utils.logError(`${MODULE_NAME}: merkleId fetch encountered an error`, error); | ||
callback(); | ||
} | ||
}; | ||
ajax(url, callbacks, undefined, {method: 'GET', withCredentials: true}); | ||
}; | ||
return {callback: resp}; | ||
} | ||
}; | ||
|
||
submodule('userId', merkleIdSubmodule); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters