How to use the tough-cookie.Cookie function in tough-cookie

To help you get started, we’ve selected a few tough-cookie examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TreeGateway / tree-gateway / test / unit / authenticator.spec.ts View on Github external
it('should be able to verify JWT authentication on requests to API via custom cookie', (done) => {
        const cookie = new Cookie({
            key: 'my-cookie',
            value: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ'
        });
        const jar = gatewayRequest.jar();
        jar.setCookie(cookie.cookieString(), 'http://localhost:8001');
        gatewayRequest.get({
            jar: jar,
            url: '/secure/get'
        }, (error: any, response: any, body: any) => {
            expect(response.statusCode).to.equal(200);
            done();
        });
    });
github flocasts / flagpole / src / browsercontrol.ts View on Github external
puppeteerCookies.forEach(puppeteerCookie => {
      cookies.push(
        new Cookie({
          key: puppeteerCookie.name,
          value: puppeteerCookie.value,
          domain: puppeteerCookie.domain,
          path: puppeteerCookie.path,
          httpOnly: puppeteerCookie.httpOnly,
          secure: puppeteerCookie.secure
        })
      );
    });
    return cookies;
github medialab / sandcrawler / src / engines / phantom.js View on Github external
.map(function(c) {
          var cookie;

          if (typeof c === 'string')
            cookie = Cookie.parse(c);
          else
            cookie = new Cookie(c);

          cookie.domain = cookie.domain || purl.hostname;
          cookie.path = cookie.path || '/';

          return cookie;
        })
        .map(helpers.serializeCookie);
github Aedron / Luoo.qy / static / js / user.js View on Github external
async function _getLoginCookie() {
    const resCookie = _formatCookie((await request({
        method: 'GET',
        uri: 'http://www.luoo.net/',
        headers: headers,
        gzip: true,
        resolveWithFullResponse: true
    })).headers['set-cookie'][0]);
    const cookie = new tough.Cookie({
        key: "LUOOSESS",
        value: resCookie.LUOOSESS,
        domain: resCookie.domain,
        path: resCookie.path
    });
    config.set({ LUOOSESS: cookie });
    return cookie;
}
github pmarkert / hyperpotamus / lib / actions / request_defaults.js View on Github external
return Promise.mapSeries(this.request_defaults, rd => {
		return context.requestDefaultsStore().putCookiePromise(new tough.Cookie(rd));
	});
};
github alrighty / react-universal-starter-kit / modules / server / utils / createServerFetch.js View on Github external
Object.keys(cookies).forEach((name) => {
    const cookie = new Cookie({
      key: name,
      value: cookies[name]
    })
    jar.setCookieSync(cookie, url)
  })
}
github medialab / sandcrawler / src / engines / static.js View on Github external
var cookieString = pool.map(function(c) {
        if (typeof c === 'string')
          return c;
        else
          return (new Cookie(c)).cookieString();
      }).join('; ');
github ekino / veggies / src / extensions / http_api / client.js View on Github external
this.cookies.forEach(cookie => {
                    if (_.isPlainObject(cookie)) {
                        this.cookieJar.setCookie(new Cookie(cookie), fullUri)
                    } else if (_.isString(cookie)) {
                        this.cookieJar.setCookie(cookie, fullUri)
                    }
                })
            }
github Aedron / Luoo.qy / static / js / user.js View on Github external
function _putCookie() {
    !isObjectEmpty(config.get('LUOOSESS')) &&
    cookieJar.setCookie(new tough.Cookie({
        key: "LUOOSESS",
        value: config.get('LUOOSESS').value,
        domain: config.get('LUOOSESS').domain,
        path: config.get('LUOOSESS').path
    }), 'http://www.luoo.net');
    !isObjectEmpty(config.get('lult')) &&
    cookieJar.setCookie(new tough.Cookie({
        key: "lult",
        value: config.get('lult').value,
        domain: config.get('lult').domain,
        path: config.get('lult').path
    }), 'http://www.luoo.net');
}
github Aedron / Luoo.qy / static / js / user.js View on Github external
function _putCookie() {
    !isObjectEmpty(config.get('LUOOSESS')) &&
    cookieJar.setCookie(new tough.Cookie({
        key: "LUOOSESS",
        value: config.get('LUOOSESS').value,
        domain: config.get('LUOOSESS').domain,
        path: config.get('LUOOSESS').path
    }), 'http://www.luoo.net');
    !isObjectEmpty(config.get('lult')) &&
    cookieJar.setCookie(new tough.Cookie({
        key: "lult",
        value: config.get('lult').value,
        domain: config.get('lult').domain,
        path: config.get('lult').path
    }), 'http://www.luoo.net');
}