Skip to content

Commit

Permalink
refactor(cookie): remove cookie-parser dependency and use the native …
Browse files Browse the repository at this point in the history
…crypto module to sign cookie
  • Loading branch information
bhavya3024 committed Nov 13, 2024
1 parent 9e3dbb4 commit 9881849
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var path = require('path');
var pathIsAbsolute = require('path').isAbsolute;
var statuses = require('statuses')
var merge = require('utils-merge');
var sign = require('cookie-signature').sign;
var crypto = require('crypto');
var normalizeType = require('./utils').normalizeType;
var normalizeTypes = require('./utils').normalizeTypes;
var setCharset = require('./utils').setCharset;
Expand Down Expand Up @@ -746,7 +746,7 @@ res.cookie = function (name, value, options) {
: String(value);

if (signed) {
val = 's:' + sign(val, secret);
val = 's:' + val + '.' + crypto.createHmac('sha256', secret).update(val).digest('base64').replace(/\=+$/, '');
}

if (opts.maxAge != null) {
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"content-disposition": "^1.0.0",
"content-type": "~1.0.4",
"cookie": "0.7.1",
"cookie-signature": "^1.2.1",
"debug": "4.3.6",
"depd": "2.0.0",
"encodeurl": "~2.0.0",
Expand Down

0 comments on commit 9881849

Please sign in to comment.