Support CipherKey type for secret

Open
#106 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript, nodejs
Domain
backend, security

Research direction

Start with index.js around line 33 and compare the current secret handling with cookie-signature's accepted key types and Node.js crypto.CipherKey documentation. Done means supporting the requested CipherKey-compatible secret values instead of only strings or string arrays while preserving existing cookie parsing and signing behavior.

Written by the indexing model from the issue text.

Description

enhancement

Currently, only string or string array types can be used as secret values.

https://github.com/expressjs/cookie-parser/blob/429cfd4bcfa66f6578af890d83d5c88be1144245/index.js#L33

But cookie-signature allows not only string, but also ArrayBufferView(TypedArray, DataView), and crypto.KeyObject.

The secret is for an HMAC key, so technically we can allow string, ArrayBuffer, Buffer, TypedArray, DataView, KeyObject, and CryptoKey, which is described in the nodejs docs. And these types are represented as crypto.CipherKey type.

This is also related to security concerns. See Using strings as inputs to cryptographic APIs

Dominant language
JavaScript
Stars
2k
Forks
237
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from expressjs/cookie-parser

All issues in expressjs/cookie-parser

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.