-
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.
* idLink - integrate new submodule idLinkSystem in to userId module * idLink - Fix unit tests * identityLink - Change submodule name from idLink to identityLink * Identity Link - Remove identity link to be default submodule
- Loading branch information
Showing
5 changed files
with
175 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* This module adds IdentityLink to the User ID module | ||
* The {@link module:modules/userId} module is required | ||
* @module modules/identityLinkSubmodule | ||
* @requires module:modules/userId | ||
*/ | ||
|
||
import * as utils from '../src/utils.js' | ||
import {ajax} from '../src/ajax.js'; | ||
import {submodule} from '../src/hook'; | ||
|
||
/** @type {Submodule} */ | ||
export const identityLinkSubmodule = { | ||
/** | ||
* used to link submodule with config | ||
* @type {string} | ||
*/ | ||
name: 'identityLink', | ||
/** | ||
* decode the stored id value for passing to bid requests | ||
* @function | ||
* @param {string} value | ||
* @returns {{idl_env:string}} | ||
*/ | ||
decode(value) { | ||
return { 'idl_env': value } | ||
}, | ||
/** | ||
* performs action to obtain id and return a value in the callback's response argument | ||
* @function | ||
* @param {SubmoduleParams} [configParams] | ||
* @returns {function(callback:function)} | ||
*/ | ||
getId(configParams) { | ||
if (!configParams || typeof configParams.pid !== 'string') { | ||
utils.logError('identityLink submodule requires partner id to be defined'); | ||
return; | ||
} | ||
// use protocol relative urls for http or https | ||
const url = `https://api.rlcdn.com/api/identity?pid=${configParams.pid}&rt=envelope`; | ||
|
||
return function (callback) { | ||
ajax(url, response => { | ||
let responseObj; | ||
if (response) { | ||
try { | ||
responseObj = JSON.parse(response); | ||
} catch (error) { | ||
utils.logError(error); | ||
} | ||
} | ||
callback(responseObj.envelope); | ||
}, undefined, { method: 'GET' }); | ||
} | ||
} | ||
}; | ||
|
||
submodule('userId', identityLinkSubmodule); |
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
Oops, something went wrong.