things-that-I-thought-were-interesting-while-building-this-follow-up-post day 2!
so here we are at the Discord (official?) library for handling these interaction webhook requests, and it requires a version of Node.js higher than what we have available on Glitch. what do we do now?
(continuity note: I’m writing this on a different computer today)
in the last post, I said I would discuss why that version is set “so high.” in fact it is not very high. Node.js 18.x is the oldest release that is still being maintained by the authors. in some cases, a library might have its minimum node version bumped to whatever the oldest supported version is even without requiring any new features [citation needed]. so one thing we might like to do is to look at the circumstances for this library having its nod minimum node version bumped.
here we’re heading off to software archaeology land. I find that I do this pretty often, but it occurs to me we might have some folks in the audience who are new to it. so let’s take some time to show how to actually go to software archaeology land, find what we need, and come back alive and wiser than when we set off.
we are currently on GitHub, which you may understand from its name, hosts repositories that are created by the version control program, Git. Git has a command called blame
for looking up who last changed a given line and when. GitHub allows us to look at this same information on a web page.
we’ll first look at this information to find out when the library developers changed this line containing the minimum node version. to do that, we’ll click this button up here to go to the blame view. (folks who know the leet-er ways to do this, have at it in the replies.) similarly if we were exploring this repository locally with the git
command line tool, we’d run git blame package.json
.
that takes us to a view where each line has its blame information shown to the left of it. let’s go back down to the minimum node version line and consult its blame information.
this line last changed 9 months ago, in a Git commit whose title is shown. our next step will be to read the commit to learn about the circumstances of the change. on GitHub, we navigate to the commit by clicking that commit title. similarly if we were on the command line, a short commit hash would be shown on that line and we’d run git show 69499c
to see the commit.
the title is “fix: remove dependency on tweetnacl,” and the diff below shows that they indeed remove the tweetnacl
package from the dependencies. tweetnacl is a cryptography library which they had used to verify the Discord server’s digital signature on incoming webhook requests. as part of removing tweetnacl, they wrote a new signature verification routine that uses…
the web crypto API. and that API is provided by Node.js itself, which makes the availability of the different cryptographic algorithms very sensitive to the Node.js version. so was this a frivolous requirement bump? no. does the library really need this version? yeah. rats.
one last thing to note before we pack it up and go home. the cryptography library that the Discord library was switching away from is tweetnacl.

the tweetnacl library on npm doesn’t have a minimum Node.js version declared in its package.json. but I’d guess that it has pretty good compatibility with older versions. behold, it hasn’t bumped its major version since 2017.
that’s good to know. we can keep that in mind as an idea to implement the cryptographic operations in a way that’s compatible with the Node.js 16 or below that we have on Glitch.
for anyone who wondered “does it matter if I make good commits with meaningful messages?” it does. now let’s go back.
back to programming. let me summarize what we found out:
- yes the discord interactions library really does need that minimum Node.js version
- it uses the web crypto API
- they had code that’s compatible with earlier versions of Node.js based on the tweetnacl library
so we’ll need to put together a library that’s compatible with at most Node.js 16, and it seems we’ll need two parts for that:
- most of the stuff from the discord interactions library that’s already compatible with older Node.js
- another way to verify a digital signature
and we’re aware that the tweetnacl library offers a way to verify that digital signature.
tune in tomorrow for uh, I think I’ll write a little about building this new discord interactions library