From 1c5ba6056aaa63c187b7f3783e3407e6affd774e Mon Sep 17 00:00:00 2001 From: Fabien O'Carroll Date: Fri, 6 Sep 2019 13:07:09 +0800 Subject: [PATCH] Removed lib/cookies no-issue This is no longer used --- ghost/members-api/lib/cookies.js | 51 -------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 ghost/members-api/lib/cookies.js diff --git a/ghost/members-api/lib/cookies.js b/ghost/members-api/lib/cookies.js deleted file mode 100644 index 627cd68c45..0000000000 --- a/ghost/members-api/lib/cookies.js +++ /dev/null @@ -1,51 +0,0 @@ -const crypto = require('crypto'); -const cookie = require('cookie'); - -const MAX_AGE = 60 * 60 * 24 * 184; - -module.exports = function cookies(sessionSecret) { - function encodeCookie(data) { - const encodedData = encodeURIComponent(data); - const hmac = crypto.createHmac('sha256', sessionSecret); - hmac.update(encodedData); - return `${hmac.digest('hex')}~${encodedData}`; - } - - function decodeCookie(data) { - const hmac = crypto.createHmac('sha256', sessionSecret); - const [sentHmac, sentData] = data.split('~'); - if (hmac.update(sentData).digest('hex') !== sentHmac) { - return null; - } - return decodeURIComponent(sentData); - } - - function setCookie(member) { - return cookie.serialize('signedin', member.id, { - maxAge: MAX_AGE, - path: '/ghost/api/v2/members', - httpOnly: true, - encode: encodeCookie - }); - } - - function removeCookie() { - return cookie.serialize('signedin', false, { - maxAge: 0, - path: '/ghost/api/v2/members', - httpOnly: true - }); - } - - function getCookie(req) { - return cookie.parse(req.headers.cookie || '', { - decode: decodeCookie - }); - } - - return { - setCookie, - removeCookie, - getCookie - }; -};