1// Add new Script 2 3if (typeof(cepEnv) == "undefined"){ //Set default env as QA if cepEnv is not defined 4 var cepEnv = 'QA'; 5} 6 7if(isERBTesting === undefined) { 8 var isERBTesting = false; 9} 10 11var scriptBaseUrl = "https://erb-qa.dnb.com"; 12var sonarBaseUrl="https://ci-mpsnare.iovation.com"; 13var currentActivity = []; 14var clientEventTransactionId; 15var trusteeEnabled = false; 16 17switch (cepEnv) { 18 case "DEV": 19 scriptBaseUrl = "http://dbdlerrap01.us.dnb.com:8080"; 20 break; 21 case "QA": 22 scriptBaseUrl = "https://erb-qa.dnb.com"; 23 break; 24 case "STG": 25 scriptBaseUrl = "https://erb-stg.dnb.com"; 26 break; 27 case "STG2": 28 scriptBaseUrl = "https://eri-stg.dnb.com"; 29 break; 30 case "DR": 31 scriptBaseUrl = "http://DBRLERBAPV01.us.dnb.com:8080"; 32 break; 33 case "PROD": 34 scriptBaseUrl = "https://erb.dnb.com"; 35 sonarBaseUrl="https://mpsnare.iesnare.com"; 36 break; 37 case "PROD2": 38 scriptBaseUrl = "https://eri.dnb.com"; 39 sonarBaseUrl="https://mpsnare.iesnare.com"; 40 break; 41 default: 42 scriptBaseUrl = "https://erb-qa.dnb.com"; 43 break; 44} 45 46function loadDeviceVerificationScripts(sessionId, app_id, event_type_id, account_code = "") { 47 getActivity(app_id, event_type_id) 48 .then(async ({activity, isTrusteeEnabled, pinPointSnippetId}) => { 49 50 if(currentActivity.includes(activity)) { 51 const email = getInputTagValues("account_code"); 52 if(!account_code) return; 53 if(email && email === account_code) return; 54 if(!email || email !== account_code) { 55 const puid = await generatePUID(account_code); 56 createInputWithValue("account_code", account_code); 57 createInputWithValue("puid", puid); 58 } 59 return 60 } 61 currentActivity.push(activity); 62 trusteeEnabled = isTrusteeEnabled; 63 pinPointId = pinPointSnippetId; 64 65 // load additional scripts 66 loadScript(isTrusteeEnabled).then(async () => { 67 if(trusteeEnabled) { 68 const { puid } = start(account_code, sessionId, activity, pinPointSnippetId); 69 clearInputValues("activity"); 70 clearInputValues("sessionid"); 71 clearInputValues("app_id"); 72 clearInputValues("event_type_id"); 73 74 createInputWithValue("activity", activity); 75 createInputWithValue("sessionid", sessionId); 76 createInputWithValue("app_id", app_id); 77 createInputWithValue("event_type_id", event_type_id); 78 79 if(puid) { 80 clearInputValues("account_code"); 81 clearInputValues("puid"); 82 83 createInputWithValue("account_code", account_code); 84 createInputWithValue("puid", puid); 85 } 86 } 87 }) 88 }).catch((err) => { 89 console.error("Error geting configuration from ERB.") 90 }); 91} 92 93async function getNewSession(account_code, app_id, event_type_id, ip_addr, sessionId) { 94 createInputWithValue("sessionid", sessionId); 95 96 let i = getIdentity(); 97 const puid = i.p.p; 98 i = { 99 ...i, 100 c: sessionId 101 }; 102 103 getIdentity = () => i; 104 105 const {activity} = await getActivity(app_id, event_type_id); 106 window["dunlog"](activity); 107 108 clientEventTransactionId = postToCEP(account_code,app_id, event_type_id, null, ip_addr, sessionId, activity, puid); 109 return clientEventTransactionId; 110} 111 112async function getEvaluationTransId(ip_addr, account_code = null) { 113 const sessionId = getInputTagValues("sessionid"); 114 const appId = getInputTagValues("app_id"); 115 const eventTypeId = getInputTagValues("event_type_id"); 116 const activity = getInputTagValues("activity"); 117 let puid = null; 118 let blackboxData = null; 119 if(trusteeEnabled) { 120 if(!account_code) { 121 account_code = getInputTagValues("account_code"); 122 puid = getInputTagValues("puid"); 123 } else { 124 if(account_code === getInputTagValues("account_code")) { 125 account_code = getInputTagValues("account_code"); 126 puid = getInputTagValues("puid"); 127 } else { 128 puid = await generatePUID(account_code); 129 } 130 } 131 } else { 132 const bbox = ioGetBlackbox(); 133 blackboxData = bbox.blackbox; 134 } 135 136 if(!account_code) { 137 account_code = ""; 138 puid = trusteeEnabled ? "N/A" : null; 139 } 140 141 return postToCEP(account_code, appId, eventTypeId, blackboxData, ip_addr, sessionId, activity, puid); 142} 143 144async function loadScript(isTFlagEnabled) { 145 const script = document.createElement("script"); 146 script.type = "text/javascript"; 147 if(isTFlagEnabled) { 148 script.src = scriptBaseUrl + "/CEP/dnbDeviceAuthentication.js"; 149 } else { 150 script.src = sonarBaseUrl + "/snare.js"; 151 } 152 153 return new Promise((resolve, reject) => { 154 script.onload = () => resolve(); 155 script.onerror = () => reject(new Error("Error while loading js: ", script.src)) 156 document.getElementsByTagName("head")[0].appendChild(script); 157 }) 158} 159 160async function setGlobalCEPData(account_code, app_id, event_type_id, ip_addr, session_id = "") { 161 if(null == account_code){ 162 account_code = ""; 163 }else if(account_code.length == 0){ 164 account_code = ""; 165 }else if(account_code == "anonymous"){ 166 account_code = ""; 167 } 168 169 const {activity, isTrusteeEnabled, pinPointSnippetId} = await getActivity(app_id, event_type_id); 170 171 if(currentActivity.includes(activity)) { 172 var inputField = document.getElementById('clientEventTransID') 173 inputField.value = clientEventTransactionId; 174 return clientEventTransactionId; 175 } 176 177 currentActivity.push(activity); 178 179 await loadScript(isTrusteeEnabled); 180 181 var {puid, sessionId} = ""; 182 var blackboxData = null; 183 184 if(isTrusteeEnabled) { 185 const data = await start(account_code, session_id, activity, pinPointSnippetId); 186 puid = data.puid; 187 } else {
188 var bbox = ioGetBlackbox(); 189 blackboxData = bbox.blackbox; 190 } 191 192 clientEventTransactionId = postToCEP(account_code,app_id, event_type_id, blackboxData, ip_addr, session_id, activity, puid); 193 return clientEventTransactionId; 194} 195 196function cretaeClientEventTransactionId(session_id, event_type_id ) { 197 var dateString = new Date(); 198 var date = dateString.getDate(); 199 var month = dateString.getMonth()+1; //January is 0! 200 var year = dateString.getFullYear(); 201 var hour = dateString.getHours(); 202 var min = dateString.getMinutes(); 203 var sec = dateString.getSeconds(); 204 var ms = dateString.getMilliseconds(); 205 206 if(date<10) { 207 date='0'+date; 208 } 209 if(month<10) { 210 month='0'+month; 211 } 212 213 var clientEventTransIDVal = session_id + '_ERB_' + event_type_id + '_CLIENTEVENTTRANSID_' + date.toString() + '_' + month.toString() + '_' + year.toString() + '_' + 214 hour.toString() + '_' + min.toString() + '_' + sec.toString() + '_' + ms; 215 216 return clientEventTransIDVal; 217} 218 219function getCEPBaseUrl(){ 220 var cepUrl; 221 if(cepEnv == 'DEV') { 222 cepUrl = 'http://dbdlerrap01.us.dnb.com:8080/CEP/'; 223 }else if(cepEnv == 'QA') { 224 cepUrl = 'https://erb-qa.dnb.com/CEP/'; 225 }else if(cepEnv == 'STG') { 226 cepUrl = 'https://erb-stg.dnb.com/CEP/'; 227 }else if(cepEnv == 'STG2') { 228 cepUrl = 'https://eri-stg.dnb.com/CEP/'; 229 }else if(cepEnv == 'DR') { 230 cepUrl = 'http://DBRLERBAPV01.us.dnb.com:8080/CEP/'; 231 }else if(cepEnv == 'PROD') { 232 cepUrl = 'https://erb.dnb.com/CEP/'; 233 }else if(cepEnv == 'PROD2') { 234 cepUrl = 'https://eri.dnb.com/CEP/'; 235 } 236 return cepUrl; 237} 238 239function postToCEP(account_code, app_id, event_type_id, bbox, ip_addr, session_id, activity="", puid="") { 240 // Generate unique CLIENT_EVENT_TRANS_ID 241 242 var cepUrl = getCEPBaseUrl() + 'IUpdateCEPLayer'; 243 var clientEventTransIDVal = cretaeClientEventTransactionId(session_id, event_type_id); 244 245 246 var inputField = document.getElementById('clientEventTransID') 247 inputField.value = clientEventTransIDVal; //Setting clientEventTransID in hidden field 248 249 if(isERBTesting) { 250 const event = new Event('input', { 251 bubbles: true, 252 cancelable: true 253 }); 254 inputField.dispatchEvent(event); 255 } 256 257 try { 258 xdr = new XDomainRequest();//For Internet Explorer 259 xdr.open("POST", cepUrl); 260 xdr.send("browserFlag=IE&client_event_trans_id=" + clientEventTransIDVal + "&account_code=" 261 + account_code + "&app_id=" + app_id + "&ip_addr=" + ip_addr + "&session_id=" + session_id + "&event_type_id=" 262 + event_type_id + "&blackbox=" + bbox + "&activity=" + activity + "&puid=" + puid); 263 } catch (e) { 264 //Send AJAX Request to CEP Servlet 265 var deviceAuthXmHttp; 266 if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, 267 // Opera, Safari 268 deviceAuthXmHttp = new XMLHttpRequest(); 269 } else {// code for IE6, IE5 270 deviceAuthXmHttp = new ActiveXObject("Microsoft.XMLHTTP"); 271 } 272 deviceAuthXmHttp.open("POST", cepUrl, false); 273 deviceAuthXmHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 274 deviceAuthXmHttp.send("browserFlag=OTHER&client_event_trans_id=" + clientEventTransIDVal + "&account_code=" 275 + account_code + "&app_id=" + app_id + "&ip_addr=" + ip_addr + "&session_id=" + session_id + "&event_type_id=" 276 + event_type_id + "&blackbox=" + bbox + "&activity=" + activity + "&puid=" + puid); 277 } finally { 278 return clientEventTransIDVal 279 } 280} 281 282async function getActivity(app_id, event_type_id) { 283 if (null == app_id) { 284 app_id = ""; 285 } 286 if(null == event_type_id){ 287 event_type_id = ""; 288 } 289 try { 290 const activity = await getToCEPForActivityDetails(app_id, event_type_id); 291 return activity; 292 } catch (error) { 293 console.error('Error fetching activity:', error); 294 return "login"; 295 } 296} 297 298function getToCEPForActivityDetails(app_id, event_type_id){ 299 var cepUrl = getCEPBaseUrl()+'CEPActivityDetails'; 300 301 return new Promise((resolve, reject) => { 302 303 try { 304 xdr = new XDomainRequest();//For Internet Explorer 305 xdr.open("POST", cepUrl); 306 xdr.onload = () => { 307 try { 308 const response = JSON.parse(xdr.responseText); 309 resolve(response); 310 } catch (e) { 311 reject(new Error("Error parsing response")); 312 } 313 }; 314 xdr.send("app_id=" + app_id + "&event_type_id=" + event_type_id); 315 } catch (e) { 316 //Send AJAX Request to CEP Servlet 317 var deviceAuthXmHttp; 318 if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, 319 // Opera, Safari 320 deviceAuthXmHttp = new XMLHttpRequest(); 321 } else {// code for IE6, IE5 322 deviceAuthXmHttp = new ActiveXObject("Microsoft.XMLHTTP"); 323 } 324 deviceAuthXmHttp.open("POST", cepUrl, false); 325 deviceAuthXmHttp.onload = () => { 326 if (deviceAuthXmHttp.status >= 200 && deviceAuthXmHttp.status < 300) { 327 try { 328 const response = JSON.parse(deviceAuthXmHttp.responseText); 329 resolve(response); 330 } catch (e) { 331 reject(new Error("Error parsing response")); 332 } 333 } else { 334 reject(new Error("Request failed: " + deviceAuthXmHttp.statusText)); 335 } 336 }; 337 deviceAuthXmHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 338 deviceAuthXmHttp.send("app_id=" + app_id + "&event_type_id=" + event_type_id); 339 } 340 });
341} 342 343function setButtonClickRequest(account_code, app_id, event_type_id, ip_addr,session_id){ 344 // iOvation predefined parameters - do not change 345 var io_install_stm = false; // do not install Active X 346 var io_exclude_stm = 12; // do not run Active X 347 var io_install_flash = false; // do not install Flash 348 var io_enable_rip = true; // collect Real IP information 349 350 351 // Generate unique CLIENT_EVENT_TRANS_ID 352 var dateString = new Date(); 353 var date = dateString.getDate(); 354 var month = dateString.getMonth()+1; //January is 0! 355 var year = dateString.getFullYear(); 356 var hour = dateString.getHours(); 357 var min = dateString.getMinutes(); 358 var sec = dateString.getSeconds(); 359 var ms = dateString.getMilliseconds(); 360 var bbox = ioGetBlackbox(); 361 if(date<10) { 362 date='0'+date; 363 } 364 if(month<10) { 365 month='0'+month; 366 } 367 368 var clientEventTransIDVal = session_id + '_ERB_' + event_type_id + '_CLIENTEVENTTRANSID_' + date.toString() + '_' + month.toString() + '_' + year.toString() + '_' + 369 hour.toString() + '_' + min.toString() + '_' + sec.toString() + '_' + dateString.getMilliseconds(); 370 document.getElementById('clientEventTransID').value = clientEventTransIDVal; //Setting clientEventTransID in hidden field 371 372 var cepRequestVal = "browserFlag=NA&client_event_trans_id=" + clientEventTransIDVal + "&account_code=" 373 + account_code + "&app_id=" + app_id + "&ip_addr=" + ip_addr + "&session_id=" + session_id + "&event_type_id=" 374 + event_type_id + "&blackbox=" + bbox.blackbox; 375 376 document.getElementById('cepRequestString').value = cepRequestVal; 377} 378 379function createInputWithValue(elementId, value) { 380 let key = "erb_"+elementId; 381 sessionStorage.setItem(key,value) 382} 383 384function getInputTagValues(elementId) { 385 const ele = sessionStorage.getItem("erb_"+elementId); 386 return ele; 387} 388 389function clearInputValues(elementId) { 390 sessionStorage.removeItem("erb_"+elementId); 391}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.