Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
{ },
config.PRIVATE_KEY.trim(),
{
"audience": headers.host[0].value,
"subject": auth.getSubject(decodedData),
"expiresIn": config.SESSION_DURATION,
"algorithm": "RS256"
} // Options
), {
path: '/',
maxAge: config.SESSION_DURATION
})
},
{
"key": "Set-Cookie",
"value" : cookie.serialize('NONCE', '', {
path: '/',
expires: new Date(1970, 1, 1, 0, 0, 0, 0)
})
}
],
},
};
callback(null, response);
} else {
unauthorized('Nonce Verification Failed', '', '', callback);
}
}
});
} catch (error) {
setCookie (key, value, options = {}) {
if (!this.options.cookie) {
return
}
const _key = this.options.cookie.prefix + key
const _options = Object.assign({}, this.options.cookie.options, options)
const _value = encodeValue(value)
const serializedCookie = serializeCookie(_key, _value, _options)
if (process.client) {
// Set in browser
document.cookie = serializedCookie
} else if (process.server && this.ctx.res) {
// Send Set-Cookie header from server side
this.ctx.res.setHeader('Set-Cookie', serializedCookie)
}
return value
}
const onCompleted = data => {
// Store the token in cookie
document.cookie = cookie.serialize('token', data.signinUser.token, {
sameSite: true,
path: '/',
maxAge: 30 * 24 * 60 * 60, // 30 days
})
// Force a reload of all the current queries now that the user is
// logged in
client.cache.reset().then(() => {
redirect({}, '/')
})
}
const writeIdentityCookie = payload => {
const domain =
process.env.NODE_ENV === 'production' ? 'opentrons.com' : undefined
global.document.cookie = cookie.serialize('ot_name', payload.name, {
domain,
maxAge: 10 * 365 * 24 * 60 * 60, // 10 years
})
global.document.cookie = cookie.serialize('ot_email', payload.email, {
domain,
maxAge: 10 * 365 * 24 * 60 * 60, // 10 years
})
}
: String(value);
if (signed) {
val = 's:' + sign(val, secret);
}
if ('maxAge' in opts) {
opts.expires = new Date(Date.now() + opts.maxAge);
opts.maxAge /= 1000;
}
if (opts.path == null) {
opts.path = '/';
}
this.append('Set-Cookie', cookie.serialize(name, String(val), opts));
return this;
};
export function clearToken() {
const cookies = cookie.parse( document.cookie );
if ( typeof cookies[ TOKEN_NAME ] !== 'undefined' ) {
document.cookie = cookie.serialize( TOKEN_NAME, false, { maxAge: -1 } );
}
}
useEffect(() => {
if (typeof window !== "undefined") {
const setCookie = cookie.serialize("theme", theme);
document.cookie = setCookie;
}
}, [theme]);
"state": request.uri,
"response_type": "code"
});
const response = {
status: '302',
statusDescription: 'Found',
body: 'Authenticating with Google',
headers: {
location : [{
key: 'Location',
value: discoveryDocument.authorization_endpoint + "?" + querystring
}],
'set-cookie' : [{
key: 'Set-Cookie',
value : cookie.serialize('TOKEN', '', { path: '/', expires: new Date(1970, 1, 1, 0, 0, 0, 0) })
}],
},
};
callback(null, response);
}
proccess.update(urlupdate, '/', function(){
res.setHeader("Set-Cookie", [
Cookie.serialize('cbv', req.query.v, {
expires: new Date(Date.now() + 900000),
path: '/'
}),
Cookie.serialize('cbu', true, {
expires: new Date(0),
path: '/'
})]);
res.send('success');
});
}else{
parsedCookies.forEach((parsedCookie: Cookie) => {
if (!areCookiesEqual(parsedCookie, createCookie(name, value, options))) {
cookiesToSet.push(
cookie.serialize(parsedCookie.name, parsedCookie.value, {
domain: parsedCookie.domain,
path: parsedCookie.path,
httpOnly: parsedCookie.httpOnly,
secure: parsedCookie.secure,
maxAge: parsedCookie.maxAge,
expires: parsedCookie.expires,
}),
)
}
})