Repository navigation
Closed
Labels
Area: Gatewayapps/gateway (patient-facing app for remote assignments)ChoreType: maintenance with no user-visible change (dependency upgrades, tooling, tests, refactors)Difficulty: LowIsolated change, about 2 hours or lessGood First IssueWell-scoped, low-risk and self-contained; a good entry point for a new contributorPriority: LowNice to have, cosmetic or speculative
Description
@cap.js/server is held at 2.0.0 in apps/gateway by the dependency update on the deps branch. The newest release eligible under the repo's 7-day minimumReleaseAge on 2026-10-04 was 4.0.5.
Why it was not upgraded
From 3.0.0, Cap#createChallenge() returns a Promise; 2.0.0 returned the challenge synchronously. The challenge route serialises the return value directly:
// apps/gateway/src/routers/cap.router.ts:28-35
router.post('/challenge', (_, res) => {
res.status(200).json(
cap.createChallenge({
challengeDifficulty: 4,
expiresMs: 60_000 * 5
})
);
});On 3.x or 4.x this route would respond with {}, a serialised Promise, so the widget could never solve a challenge. No automated check below e2e would catch it:
tscmisses it, becauseres.jsonaccepts any value.cap.router.test.tsonly covers$VerifyRequest.
Nothing else used here changed between 2.0.0 and 4.0.5:
- The
createChallengeoptions andredeemChallenge/validateTokenbehave as before. - The
Solutiontype and the constructor'snoFSState(apps/gateway/src/lib/cap.ts:3) are unchanged. - The wire format is still
{ challenge: { c, s, d }, token, expires }, which the installed@cap.js/widget0.1.58 accepts. - 4.0.5 has no peer dependencies.
Upstream publishes no release notes for 3.x or 4.x. The comparison above comes from diffing the 2.0.0, 3.0.0 and 4.0.5 tarballs.
What is required
- Make the
/challengehandler async andawait cap.createChallenge(…). The same file already wraps async handlers inah(lines 39 and 53). - Bump
@cap.js/serverto^4inapps/gateway/package.json. - Add a unit test asserting that the
/challengeresponse carrieschallengeandtoken. - Run
testing/src/specs/remote-assignment.spec.tsand the rest of the e2e suite.
Metadata
Metadata
Assignees
Labels
Area: Gatewayapps/gateway (patient-facing app for remote assignments)ChoreType: maintenance with no user-visible change (dependency upgrades, tooling, tests, refactors)Difficulty: LowIsolated change, about 2 hours or lessGood First IssueWell-scoped, low-risk and self-contained; a good entry point for a new contributorPriority: LowNice to have, cosmetic or speculative
Activity
joshunrau commentedon Oct 26, 2026
Fixed by f49823d on #1660, which is still open (
CONFLICTING, review required, last updated 2026-10-07).main(d86740e) still pins^2.0.0and has the synchronous handler atapps/gateway/src/routers/cap.router.ts:28-35.Corrections
/challengetest tocap.router.test.ts, and it assertschallengeandtoken. It would still pass after the bump without theawait, because the mock is an untypedvi.fn()(L11-L17) set withmockReturnValueOnce(L68). What catches the bug in f49823d ismockResolvedValueOnce, plus typing the mocks asvi.fn<Cap['createChallenge']>()so a synchronous mock no longer type-checks. Keep both if this is redone outside build: upgrade dependencies held back by breaking changes #1660.remote-assignment.spec.tsnever opens the gateway. The specs that solve a real challenge are intesting/src/specs/gateway-assignment.spec.ts: the@smoketest (L67) and the malformed-submission test (L146). If/challengeanswers{}, each fails only when its wait forBeginruns out at 120 s (L88, L158).Plan
mainby itself.apps/gateway/package.json,cap.router.tsandcap.router.test.tsare identical at its parent and atmain. Itspnpm-lock.yamlhunks apply with only line offsets, and the@types/node@22.19.21andundici-types@6.21.0entries it drops are used only by@cap.js/server@2.0.0onmaintoo. It comes after build: upgrade dependencies held back by breaking changes #1660's Vitest 5 commit but does not depend on it:vi.fn<T>()andmockResolvedValueOnceare typed the same way in the Vitest 4.1.11 onmain. 4.0.5 is still the newest release./api/auth/verifyrequest test atgateway-assignment.spec.ts:273:POST ${gatewayURL}/api/auth/challenge, then assert thatchallenge.c,challenge.sandchallenge.dare numbers andtokenis a string. It needs no proof of work, and it fails in seconds with a readable diff instead of a timeout.Closing
#1660's body has
Closes #1624, #1626, …, #1612, …on one line. GitHub links only the first number, so #1624 is the PR's only closing reference, and merging it as it stands leaves this issue and 12 others open. Put the keyword before each number (Closes #1624, closes #1626, …). A cherry-pick PR needs its ownCloses #1612.Triage note written with Claude Code. Code references point at
main@d86740e.build(gateway): upgrade @cap.js/server to 4