Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
url = url.toLowerCase();
if (_indexOfInstanceProperty(url).call(url, "_api") !== -1) url = url.split("_api")[0];else if (_indexOfInstanceProperty(url).call(url, "_vti_bin/client.svc/processquery") !== -1) url = url.split("_vti_bin/client.svc/processquery")[0]; // check cache
if (settings.cache) digest = global._SP_CACHE_REQUESTDIGEST[url];
if (!digest) {
_context2.next = 11;
break;
}
if (!(new Date().getTime() - new Date(digest.split(",")[1]).getTime() < 86400000)) {
_context2.next = 11;
break;
}
return _context2.abrupt("return", _Promise.resolve(digest));
case 11:
if (!(global._SP_ISBROWSER && document && settings.cache)) {
_context2.next = 17;
break;
}
e = document.querySelector("#__REQUESTDIGEST");
if (!e) {
_context2.next = 17;
break;
}
digest = e.value; // cache
if (!(global._SP_ISBROWSER && document && settings.cache)) {
_context2.next = 17;
break;
}
e = document.querySelector("#__REQUESTDIGEST");
if (!e) {
_context2.next = 17;
break;
}
digest = e.value; // cache
global._SP_CACHE_REQUESTDIGEST[url] = digest;
return _context2.abrupt("return", _Promise.resolve(digest));
case 17:
_context2.next = 19;
return ajax.call(this, {
url: url + "/_api/contextinfo",
method: "POST"
});
case 19:
data = _context2.sent;
digest = data.d.GetContextWebInformation.FormDigestValue; // cache
global._SP_CACHE_REQUESTDIGEST[url] = digest;
if (global._SP_ISBROWSER && document) {
e = document.querySelector("#__REQUESTDIGEST");
url: url + "/_api/contextinfo",
method: "POST"
});
case 19:
data = _context2.sent;
digest = data.d.GetContextWebInformation.FormDigestValue; // cache
global._SP_CACHE_REQUESTDIGEST[url] = digest;
if (global._SP_ISBROWSER && document) {
e = document.querySelector("#__REQUESTDIGEST");
if (e) e.value = digest;
}
return _context2.abrupt("return", _Promise.resolve(digest));
case 26:
_context2.prev = 26;
_context2.t0 = _context2["catch"](0);
return _context2.abrupt("return", _Promise.reject(_context2.t0));
case 29:
case "end":
return _context2.stop();
}
}
}, _callee, this, [[0, 26]]);
}));
data = data.getElementsByTagName('PrincipalInfo');
for (i = 0, lenR = data.length; i < lenR; i++) {
children = data[i].childNodes;
aResult[i] = [];
for (j = 0, lenC = children.length; j < lenC; j++) {
name = children[j].nodeName;
value = children[j].firstChild;
if (value) value = value.nodeValue;
aResult[i].push(name);
aResult[i][name] = value;
}
}
return _context.abrupt("return", _Promise.resolve(aResult));
case 24:
_context.prev = 24;
_context.t1 = _context["catch"](0);
return _context.abrupt("return", _Promise.reject(_context.t1));
case 27:
case "end":
return _context.stop();
}
}
}, _callee, this, [[0, 24]]);
}));