Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(res => {
const sessionCookie = new Cookie(res.header['set-cookie'][0]);
const cookieValue = decodeURIComponent(sessionCookie.value);
cookieValue.substr(0, 2).should.equal('s:');
return signature.unsign(cookieValue.substr(2), secret);
})
.then(decodedCookie => queryPromise('SELECT sid FROM session WHERE sid = $1', [decodedCookie]))
Jar.prototype.setCookies = function (cookies) {
cookies = Array.isArray(cookies) ? cookies : cookies.split('; ');
for (let i = 0; i < cookies.length; i++) {
const cookie = new Cookie.Cookie(cookies[i].trim());
this.cookies[cookie.name] = cookie;
}
};
beforeEach(function () {
cookie = new Cookie('sessionid=123;domain=.example.com;path=/');
agent.cookieJar.setCookie(cookie);
contentType = 'application/x-www-form-urlencoded';
form.method = 'POST';
form.enctype = contentType;
agent.submit(form, null, {}, {}, function (err, page) {
submitErr = err;
submitPage = page;
});
});
.forEach(cookieStr => {
const cookie = new Cookie(cookieStr);
if (!cookie.domain) {
cookie.domain = domain;
}
if (!cookie.path) {
cookie.path = path;
}
cookieJar.setCookie(cookie);
});
},
submitExample = async url => {
const agent = newAgent(),
cookie = new Cookie("sessionid=123;domain=.example.com;path=/"),
username = "MYUSERNAME",
password = "MYPASSWORD",
requestData = 'username='+username+'&password='+password,
form = {
page: {uri: url},
action: 'login',
method: 'POST',
enctype: 'application/x-www-form-urlencoded',
requestData: () => {
return requestData;
},
addButtonToQuery: () => {}
};
agent.setCookie(cookie);