MCPcopy Create free account
hub / github.com/6dylan6/jdpro / build

Method build

function/magic.js:422–486  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

420 }
421
422 build(url) {
423 if (url.match(/&callback=(jsonpCBK(.*))&/)) {
424 let cb = url.match(/&callback=(jsonpCBK(.*))&/);
425 url = url.replace(cb[1], this.randomCallback(cb[2].length || 0))
426 }
427 let stk = decodeURIComponent(this.getQueryString(url, '_stk') || '');
428 if (stk) {
429 let ens, hash, st = '',
430 ts = this.now('yyyyMMddHHmmssSSS').toString(),
431 tk = this.algo.tk, fp = this.algo.fp, em = this.algo.em;
432 if (tk && fp && em) {
433 hash = em(tk, fp, ts, this.appId, CryptoJS).toString(
434 CryptoJS.enc.Hex)
435 } else {
436 const random = '5gkjB6SpmC9s';
437 tk = 'tk01wcdf61cb3a8nYUtHcmhSUFFCfddDPRvKvYaMjHkxo6Aj7dhzO+GXGFa9nPXfcgT+mULoF1b1YIS1ghvSlbwhE0Xc';
438 fp = '9686767825751161';
439 hash = CryptoJS.SHA512(
440 `${tk}${fp}${ts}${this.appId}${random}`,
441 tk).toString(CryptoJS.enc.Hex);
442 }
443 stk.split(',').map((item, index) => {
444 st += `${item}:${this.getQueryString(url, item)}${index
445 === stk.split(',').length - 1 ? '' : '&'}`;
446 })
447 ens = encodeURIComponent(
448 [''.concat(ts), ''.concat(fp),
449 ''.concat(this.appId), ''.concat(tk),
450 ''.concat(CryptoJS.HmacSHA256(st, hash.toString()).toString(
451 CryptoJS.enc.Hex))].join(';'));
452 if (url.match(/[?|&]h5st=(.*?)&/)) {
453 url = url.replace(url.match(/[?|&]h5st=(.*?)&/)[1], 'H5ST')
454 .replace(/H5ST/, ens)
455 }
456 let matchArr = [/[?|&]_time=(\d+)/, /[?|&]__t=(\d+)/,
457 /[?|&]_ts=(\d+)/,
458 /[?|&]_=(\d+)/, /[?|&]t=(\d+)/, /[?|&]_cfd_t=(\d+)/]
459 for (let ms of matchArr) {
460 if (url.match(ms)) {
461 url = url.replace(url.match(ms)[1], Date.now())
462 }
463 }
464 let t = this._tk();
465 if (url.match(/strPgUUNum=(.*?)&/)) {
466 url = url.replace(url.match(/strPgUUNum=(.*?)&/)[1], t.tk)
467 if (url.match(/strPhoneID=(.*?)&/)) {
468 url = url.replace(url.match(/strPhoneID=(.*?)&/)[1], t.id)
469 }
470 if (url.match(/strPgtimestamp=(.*?)&/)) {
471 url = url.replace(url.match(/strPgtimestamp=(.*?)&/)[1],
472 t.ts)
473 }
474 }
475 if (url.match(/jxmc_jstoken=(.*?)&/)) {
476 url = url.replace(url.match(/jxmc_jstoken=(.*?)&/)[1], t.tk)
477 if (url.match(/phoneid=(.*?)&/)) {
478 url = url.replace(url.match(/phoneid=(.*?)&/)[1], t.id)
479 }

Callers 2

getMethod · 0.95
postMethod · 0.95

Calls 7

randomCallbackMethod · 0.95
getQueryStringMethod · 0.95
nowMethod · 0.95
_tkMethod · 0.95
HmacSHA256Method · 0.80
emFunction · 0.50
matchMethod · 0.45

Tested by

no test coverage detected