Repository navigation
Conversation
…ertest 7, ESLint 9)
The old test stack (mocha 5, istanbul 0.4, chai 3, sinon 4, ESLint 4,
supertest 3) is unmaintained. This moves it to current releases that run
on Node 20, 22 and 24:
- mocha 11: test/mocha.opts becomes .mocharc.yml with the same options.
- c8 replaces istanbul. It still writes lcov to ./coverage and prints a
summary (.c8rc.json). No threshold is enforced, same as before.
- chai 4: `.to.be.function` was never a real assertion and chai 4
rejects it, so defer.test.js uses `.to.be.a('function')`.
- sinon 21: `sinon.sandbox.create()` becomes `sinon.createSandbox()`.
- supertest 7 binds its test server to 127.0.0.1. supertest 3 listened
on every address but connected to 127.0.0.1, so on macOS another
process holding the same port on loopback sometimes answered, and API
tests failed at random.
- ESLint 9: .eslintrc becomes eslint.config.js with the same rules,
minus valid-jsdoc (ESLint 9 removed it). Two settings keep ESLint 4's
behavior: catch parameters are not checked by no-unused-vars, and
unused disable comments are not reported. ESLint 9 counts destructuring
defaults toward complexity, so lib/setup.js gets one
`eslint-disable-next-line complexity`.
npm 11 converted the v1 lockfile to v3 but left out amphora-auth's
clayhandlebars peer, so `npm ci` refused the lockfile. `npm dedupe`
added the peer. Its version ranges also moved clay-log (1.3.1 to 1.5.5),
lodash (4.17.11 to 4.18.1), glob and js-yaml up within their ranges.
Other runtime dependency versions are unchanged here.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The CircleCI test jobs ran on the deprecated circleci/node 10, 12 and 14 images. Replace them with a single parameterized `test` job that runs on cimg/node 20.20, 22.23 and 24.21: - It installs with `npm ci` and caches ~/.npm, keyed on package-lock.json, instead of caching node_modules keyed on package.json. - It starts a cimg/redis:7.2 service container and sets CLAY_COLLAB_TEST_REDIS=redis://localhost:6379 for tests that need a real Redis. Nothing reads the variable yet. deploy_package now runs on cimg/node:24.21 with `npm ci`. Tags with a `-` still publish under the `prerelease` dist-tag. The release tag filter used to accept only `vX.Y.Z` and `vX.Y.Z-N`. It now accepts any `vX.Y.Z-<prerelease>`, for example `v9.0.0-rc.1`. deploy_docs builds the docusaurus 1 site and stays on Node 14, as before. Its image is now pinned to cimg/node:14.21. cimg images ship without apt package lists, so the job runs `apt-get update` before it installs awscli. The config moves to version 2.1 so the job can take parameters. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- engines.node becomes ">=20". The `engine-strict` key is removed. npm only reads that setting from .npmrc, so in package.json it did nothing. - Remove dependencies that nothing in lib/ requires: basic-auth, eventify, express-flash, express-session, js-yaml, template2env and vhost. amphora-auth declares its own copies of the auth and session packages. - Remove the `handlebars` peerDependency. amphora does not require handlebars. - glob is only used by test/index.js, so it moves to devDependencies. coveralls and rimraf were never used and are removed. - Raise minimum versions within their current majors: amphora-auth ^2.1.0, bluebird ^3.7.2, body-parser ^1.20.3, clay-log ^1.5.0, express ^4.21.2, highland ^2.13.5, ioredis ^4.28.5 and lodash ^4.17.21. Express stays on 4.x and ioredis on 4.x. - node-fetch moves from ^1.3.0 to ^2.7.0, which is a major version. It is only used inside lib/rest.js, which index.js does not export, for webhook calls. Those calls send the same requests and give the same results, log lines and error messages on 1.7.3 and 2.7.0. - Add a `files` list so the package contains index.js and lib/ without tests. npm adds README, LICENSE and package.json on its own. lib/routes.js lists lib/routes/ at runtime, but amphora-fs getFiles already skipped *.test.js and readme.md, so the route list is the same. The lockfile was regenerated from scratch with npm 11 on Node 24. It installs with `npm ci` on npm 10 (Node 20) and npm 11 (Node 24). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
listDeepObjects runs when amphora composes components, replaces
versions on publish, clones or validates pages, splits cascading PUTs
and bootstraps. On every pass through its loop it rebuilt both the
result list and the queue with concat, so the cost grew with the square
of the number of objects. It now pushes into both arrays in place. The
result holds the same objects (not copies) in the same order. A
component with N child refs, on Node 24:
20 refs: 14.7 µs -> 6.0 µs
200 refs: 173 µs -> 49 µs
2000 refs: 8.9 ms -> 0.47 ms
10000 refs: 154 ms -> 2.4 ms
The new tests keep a copy of the concat implementation. They check
that both versions return the same objects in the same order, with no
filter, a property filter, a function filter and a matches-object
filter, for nested data, arrays and a page-sized component. Three
snapshot tests fix the order. All of them pass against the old code
too.
In uriToUrl, `a && b || c` was parsed as `(a && b) || c`. With
protocol `https` and no port (no argument and no PORT env), it called
`undefined.toString()` and threw. The port check now wraps both
default-port conditions. Every input that did not throw before returns
the same URL as before. The https case now returns
`https://host/path`. New tests cover default and non-default ports for
both protocols, numeric ports, and a missing PORT. Only the https test
fails against the old code.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
amphora 9 targets Node 24 (Active LTS); Node 20 reached end of life in April 2026. engines is now >=24, .nvmrc pins 24, and CI runs the suite on Node 24 only. The DEP0169 warning for url.parse() in uriToUrl only fires for application code, not for amphora running from a site's node_modules, so sites won't see it. uriToUrl keeps url.parse() so its output stays exactly the same.
c4f97a6 raised engines.node to >=24 in package.json but left the root entry in package-lock.json at >=20. Regenerated with `npm install --package-lock-only` on Node 24; nothing else changes.
Node 24 warns about url.parse() (DEP0169) whenever code outside
node_modules calls it, which includes amphora's own tests and sites that
load amphora through npm link or a file: dependency. amphora called it
in six places: isUrl, uriToUrl and urlToUri, the 301 for a _uris
redirect in render.js, and the redirect uris written on publish.
They now share references.parseUrl(). WHATWG URL can't stand in for
url.parse() on its own, because the two encode paths differently: URL
leaves ' and | alone, percent-encodes non-ASCII characters, resolves
../ segments and drops an empty ? or #. Those differences would change
res.locals.url, the _uris keys pages are published under and the
redirect targets. So parseUrl() takes the hostname from URL (which also
validates the host, lower-cases it and converts it to punycode) and cuts
the path, query and hash from the url itself, escaping the same 14
characters url.parse() escaped and turning backslashes before the query
into slashes, as url.parse() did.
I compared the old and new functions on Node 24: 360,000 combinations of
realistic hosts, paths, queries and hashes, and 1.8 million random
mutations of the path, query and hash using every ASCII character plus
non-ASCII, NBSP, BOM and lone surrogates. All results were identical.
The only differences are for hosts with characters that aren't valid in
a hostname, where url.parse() moved the rest of the host into the path:
- Hosts that WHATWG URL rejects (spaces, control characters, %, |, ^,
<, >, or a bad port): isUrl() is false for them, so such a url can no
longer be published, and urlToUri() throws "Invalid url" for them.
uriToUrl() throws "Invalid uri". Its hosts come from site config, and
the vhost router only runs it for requests whose hostname matches a
configured site.
- Hosts with ", ', ;, `, { or }, which URL accepts: uriToUrl() and the
redirect path keep these characters in the host. isUrl() and
urlToUri() give the same results as before.
- isUrl() is also false for "host:port/path" with no protocol, which
url.parse() read as protocol "host:" and host "port".
- uriToUrl() drops a user@ prefix from the uri.
- Publishing skips the redirect when the old or new url has no valid
host, instead of pointing the old uri at a uri like
"nullnymag.com/new.html". The new url is then rejected as before.
Tests pin the escaping, non-ASCII paths, dot segments, backslashes, empty
query and hash, IDN and IPv6 hosts, ports, the redirect path and the
publish redirect uris to url.parse()'s results; all of those also pass
on the old code. The tests for the changes above fail on the old code.
The new functions are also faster (uriToUrl about 0.7 µs instead of 1.3).
The flat config kept ecmaVersion 2018 from the old .eslintrc, so code using syntax Node 24 supports, such as ?. and ??, failed lint with a parsing error. 'latest' (the flat-config default) fixes that. No existing file changes its lint result, on this branch or on jordan/amphora-9.
This branch is the base for amphora 9, but its breaking changes (Node 24, removed dependencies, the published files list, and the stricter url checks from the url.parse() change) were only written up on the collaboration branch, mixed with that feature. v9-changes.md here covers just this branch. The README's Installation section now says Node 24 is required. Compared with the collaboration branch's text, the audit sentence is corrected: the 19 production advisories left come from amphora-auth and from js-yaml 3 under amphora-fs and clayutils, not only from amphora-auth. Merging this into jordan/amphora-9 will conflict in v9-changes.md (both branches add it); keep its "New" section and take the rest from here.
bc45bb8 ran every url's host through WHATWG URL. url.parse() never gave a javascript: url a host, so isUrl() used to be false for "javascript://nymag.com/%0aalert(1)" and pages.js refused to publish a page at it. After bc45bb8, isUrl() was true, urlToUri() returned "nymag.com/\nalert(1)" and the page published with that url as its meta.url. Anyone who can edit a page sets its url or customUrl, so this reopened the javascript: url XSS the check used to stop. parseUrl() now gives javascript: urls no hostname, as url.parse() did: publishing rejects them again and writes no redirect for them. Hosts are also parsed as http whatever the protocol, because url.parse() read them all the same way. For a protocol it doesn't know, URL kept the host as written ("foo://NYMAG.com/a" gave "NYMAG.com/a"), and for file: it dropped localhost and rejected a port or a user name. Checked on Node 24 against url.parse(): 2 million random http and https urls whose host is a domain name (IDN and upper case included), localhost, a dotted IPv4 address or a shortest-form IPv6 address, with or without a port, give the same isUrl, urlToUri, uriToUrl and redirect results. The new tests fail on the previous commit.
v9-changes.md said every url with a valid host gives exactly the same results as on 8.x, and bc45bb8 said the same of isUrl() and urlToUri(). That holds for http and https urls whose host is a domain name, localhost, a dotted IPv4 address or a shortest-form IPv6 address, but not for other hosts URL accepts: it writes out short and hex IPv4 addresses, shortens IPv6 ones, decodes percent escapes, and keeps " ' ; ` { } in the host and lower-cases all of it where url.parse() moved the rest of the host into the path. Hosts over 255 characters are now accepted, and a host whose last label is a number but isn't an IPv4 address is now rejected. The list of rejected hosts also named % on its own, but URL decodes valid escapes first. List each case with an example. The audit note said amphora-fs gets js-yaml 3 through nymag-fs. It depends on js-yaml directly; only clayutils gets it through nymag-fs.
26fdf40 gave the test job a cimg/redis:7.2 container and set CLAY_COLLAB_TEST_REDIS for the collaboration store tests, which only exist on jordan/amphora-9. Nothing on this branch reads the variable, so every CI run started a Redis container for nothing, and the Node 24 base branch carried part of a feature built on top of it. jordan/amphora-9 needs both back. It has not changed these lines since 26fdf40, so merging or rebasing onto this commit drops them without a conflict, and its Redis store tests then skip in CI instead of failing.
The trim regex retried its trailing alternative from every character of a whitespace run in the middle of a url, so a url with tens of thousands of spaces took seconds to parse (2 s at 64,000 on Node 24). url.parse() did it in milliseconds. A page's url reaches isUrl() and urlToUri() straight from a publish request body, so one request could stall the event loop. A lookbehind starts the trailing match only at the start of a run, which makes it linear and gives the same output.
The 9.0 notes and the commit that replaced url.parse() named only host:port/path as a url isUrl() now rejects for lack of a protocol. The rule is wider: url.parse() read what followed any protocol except http, https, ftp, gopher, file, ws, wss and javascript as the host even without //, so foo:bar/baz and data:text/html,... were urls on 8.x and urlToUri() gave "bar/baz" and "text/html,...". parseUrl() requires protocol://, so isUrl() is false and urlToUri() throws for all of them. host:port/path is one case of this. The behavior is unchanged; the notes and tests now say it.
Behind 'trust proxy', req.protocol comes from X-Forwarded-Proto, so it can be empty or something like 'http/1.1'. parseUrl() returns null for a url that doesn't start with a valid protocol and ://, so redirecting a _uris entry threw a TypeError where url.parse() used to give a path. The path is the same for http and https, so parse the uri as http.
url.parse() compared the protocol to http, https, ftp, gopher, file, ws and wss case-sensitively, so HTTP:nymag.com/x and Https:www.nymag.com/x were urls on 8.x and are rejected now. The 9.0 notes listed those protocols as exceptions without saying so, which read as if mixed-case ones were unaffected. Add a test for them next to the lower-case case.
url.parse() cut the host at ", ', ;, `, {, } or %, so a url whose host
started with one of them (also after user@) had no host and 8.x refused
to publish it. URL accepts these hosts, and it no longer throws URIError
for an invalid % escape in the user name. The notes only listed hosts
over 255 characters, so say these urls are valid now and pin it in a test.
Replacing url.parse() with WHATWG URL silenced Node 24's DEP0169 warning, but review kept finding urls that now parse differently (hosts URL rewrites, urls 8.x accepted and 9 rejects or the reverse, a missing 301 for an old url). Urls decide where pages are published and redirected, and the warning only shows when amphora is loaded from outside node_modules, so url handling stays exactly as on 8.x. Reverts bc45bb8, 95a08a9, 574695b, 0d884e8, b194345, 03da05c, eb1fe50 and e8535a6, and the url notes in v9-changes.md; lib/ is back to c4f97a6.
Node 26.12.1 is the first 26.x with the October 21 2026 security fixes (a Brotli decoder out-of-bounds write, TLS hostname checks, DNS NUL truncation). engines is now >=26.12.1 and .nvmrc pins 26.12.1. All 824 tests pass on it. - body-parser 1.20.8 -> 1.20.9 (in range): fixes a denial of service from trailing bytes after a compressed request body. - Test tooling: mocha 11 -> 12 (fixes serialize-javascript RCE and a diff DoS in its tree) and levelup 1 -> 5 / memdown 1 -> 6 with encoding-down. These are devDependencies only; nothing in the published package changes. - memdown 1 kept one process-wide store per location, which the tests relied on when db.test.js and the API tests each created a Storage. The fixture now shares one store explicitly, and keeps levelup 1's utf8 strings and its String(undefined) on put, so no test expectation changed. - The release script moves from .circleci/scripts to scripts/.
CircleCI is no longer used. Three workflows replace the old config: - ci.yml: lint and test on pull requests and pushes to master, on the Node version in .nvmrc. One job, since there is one supported Node now. Also callable by the release workflow. - release.yml: when `npm run release` pushes a vX.Y.Z tag, run the tests, check the tag matches package.json, and publish to npm with provenance (versions with a "-" go to the prerelease tag, as before). Uses an NPM_TOKEN secret, or npm trusted publishing once configured for the package. - docs.yml: build the Docusaurus site and sync it to the docs bucket when docs change on master, assuming an AWS role through GitHub's OIDC provider (repository variable DOCS_AWS_ROLE) instead of stored keys. Actions are pinned by commit SHA. The README badge now shows the CI status.
lib/rest.js exported node-fetch's fetch, and its one user, lib/services/notifications.js, posts site webhooks with a method, a header and a text or JSON body: nothing node-fetch did that the built-in fetch doesn't. exports.fetch is now a function that calls the global fetch when it is called, so tests keep stubbing exports.fetch as before. 825 tests pass.
package.json still said github.com/nymag/amphora. npm checks repository.url against the repository that signs a release, so publishing with provenance or through npm trusted publishing from clay/amphora would be rejected (E422). Adds bugs.url as well.
This was referenced Nov 6, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prepares amphora 9: it requires Node 26.12.1 (the first 26.x with the October 2026 security fixes), gets current tooling and a smaller install, and moves CI and releases from CircleCI to GitHub Actions. No runtime behavior change for sites apart from the Node requirement and the removed dependencies below.
Changes
enginesis>=26.12.1,.nvmrcpins 26.12.1, CI tests on it, and the README says so. Node 20 reached end of life in April 2026.createSandbox), supertest 7 (fixes the flaky port-collision failures), ESLint 9 flat config translated 1:1 and set to parse current syntax (?.,??). The test storage mock moves to levelup 5 / memdown 6 and shares one store explicitly, as memdown 1 did implicitly; no test expectation changed.ci.ymllints and tests on the Node version in.nvmrc, on every pull request and on pushes to master.release.yml:npm run release <patch|minor|major|prepatch|preminor|premajor>from master pushes avX.Y.Ztag. The workflow re-runs the checks, verifies the tag matchespackage.jsonand publishes to npm with provenance. Versions with a-(v9.0.0-rc.1) go to theprereleasetag.docs.ymlbuilds the docs site and uploads it when docs change on master.requires are removed:basic-auth,eventify,express-flash,express-session,js-yaml,template2env,vhost, and thehandlebarspeer.node-fetchis removed too. It was used only for the publish webhooks, which now call Node's built-infetch(lib/rest.js; tests still stubexports.fetch).fileslist: 46 files instead of 194, and deep requires oflib/still work.listDeepObjectsno longer copies arrays as it walks (~19x faster at 2,000 refs).uriToUrlno longer throws for https without a port.v9-changes.mdlists what's breaking, improved and known.Verified
lib/changed only inlib/rest.js(built-in fetch); sites has not been re-run against that yet.Before merging
Lint and test (Node 26)instead.NPM_TOKENsecret, or npm trusted publishing set up for this repository andrelease.yml. The docs upload needs theDOCS_AWS_ROLErepository variable.Breaking
Node ≥ 26.12.1, and the removed dependencies. sites already declares its own copies.
Known
Amphora still parses urls with
url.parse(), exactly as on 8.x. Node prints its deprecation warning (DEP0169) only when amphora is loaded from outsidenode_modules(npm link, afile:dependency). A rewrite to the URL API was tried and dropped, because urls decide where pages are published and redirected and review kept finding inputs that parsed differently. The history has the attempt and its revert; the net diff has neither.First of two PRs; the opt-in collaboration feature is stacked on this one.