Skip to content

Add missing sha256 support to fix signedcookiesession compilation error#283

Merged
ringabout merged 3 commits intodevelfrom
copilot/fix-signedcookiesession-error
Jan 9, 2026
Merged

Add missing sha256 support to fix signedcookiesession compilation error#283
ringabout merged 3 commits intodevelfrom
copilot/fix-signedcookiesession-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 9, 2026

The signedcookiesession module failed to compile with newer nimcrypto versions due to missing sha256 type support in the signing module.

Root Cause

The original code used sha2 as a union type, which is no longer directly exported by nimcrypto. When refactored to use individual SHA-2 types (sha224, sha384, sha512, etc.), sha256 was accidentally omitted.

Changes

  • Added sha256 to BaseDigestType union type
  • Added Sha256Type to BaseDigestMethodType enum
  • Added case handlers for Sha256Type in getSignatureEncode() and getSignatureDecode()
# Before - sha256 missing from type union
BaseDigestType* = sha1 | sha224 | sha384 | sha512 | ...

# After - sha256 included
BaseDigestType* = sha1 | sha224 | sha256 | sha384 | sha512 | ...

The fix ensures SHA-256 hashing is available alongside other SHA-2 variants (SHA-224, SHA-384, SHA-512, SHA-512/224, SHA-512/256).

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https /usr/lib/apt/methods/https (dns block)
  • nim-lang.org
    • Triggering command: /usr/bin/curl curl REDACTED -sSf -o choosenim-init.sh (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>signedcookiesession compilation error</issue_title>
<issue_description>prologue/middlewares/signedcookiesession doesn't compile,

~$ nim r test.nim 
Hint: used config file '~/.choosenim/toolchains/nim-2.2.4/config/nim.cfg' [Conf]
Hint: used config file '~/.choosenim/toolchains/nim-2.2.4/config/config.nims' [Conf]
..................................................................................................................................................................................................................................................
~/.nimble/pkgs2/prologue-0.6.6-433777a19c0bf630753006f0646c5a6dbbfd4b74/prologue/signing/signing.nim(48, 28) Error: undeclared identifier: 'sha2'
candidates (edit distance, scope distance); see '--spellSuggest': 
 (0, 2): 'sha2'

probably nimcrypto changed their api, version 0.6.0 works but the most recent one doesn't.</issue_description>

<agent_instructions>fix this issue</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix signedcookiesession compilation error Add missing sha256 support to fix signedcookiesession compilation error Jan 9, 2026
Copilot AI requested a review from ringabout January 9, 2026 12:59
@ringabout
Copy link
Copy Markdown
Member

@copilot don't forget to add a changelog

@ringabout ringabout marked this pull request as ready for review January 9, 2026 13:43
Copilot AI review requested due to automatic review settings January 9, 2026 13:43
@ringabout ringabout merged commit a0a6e4c into devel Jan 9, 2026
4 of 5 checks passed
@ringabout ringabout deleted the copilot/fix-signedcookiesession-error branch January 9, 2026 13:43
Copilot stopped work on behalf of ringabout due to an error January 9, 2026 13:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a compilation error in the signedcookiesession module by adding missing SHA-256 support. When the code was refactored to use individual SHA-2 types instead of the sha2 union type (which is no longer exported by newer nimcrypto versions), sha256 was accidentally omitted.

Key changes:

  • Added sha256 to the BaseDigestType union type alongside other SHA-2 variants
  • Added Sha256Type to the BaseDigestMethodType enum
  • Added case handlers for Sha256Type in both signature encode and decode functions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

signedcookiesession compilation error

3 participants