on master help sign in
Fix bug #9: tighten Timestamp annotations on handleChallenge, handleVerifyAuth, doPoll
commitde66ca82f7afccbebdcc877770afe7628b9c8c27 authoriko <mail@iko.soy> dateFri 29 May 2026, 19:10 (4 months ago) parent1f0ce2e
1 file changed+3−3
server.knot+3−3
server.knot+3−3
@@ -605,7 +605,7 @@ forwardQueuedToServer = \pubkey server -> atomic (do
605605-- Capped per-key (maxChallengesPerKey); per-pubkey rate limiting is enforced
606606-- by the route's `rateLimit` clause. The IP is recorded so /auth/verify can
607607-- require the same client.
608−handleChallenge : PubkeyHex -> Text -> IO {rw *challenges, clock, random} (Result HttpError {challenge: Text, expiresAt: Int})
608+handleChallenge : PubkeyHex -> Text -> IO {rw *challenges, clock, random} (Result HttpError {challenge: Text, expiresAt: Timestamp})
609609handleChallenge = \pubkey clientIp -> do
610610 t <- now
611611 challenge <- genToken 48
@@ -623,7 +623,7 @@ handleChallenge = \pubkey clientIp -> do
623623-- On success, mints a session token, records local presence (`pubkey` is now
624624-- live on this server), and gossips an `online` event to known peers. If
625625-- `revokeOthers` is set, all other sessions for the same pubkey are dropped.
626−handleVerifyAuth : PubkeyHex -> Text -> Text -> Bool -> Text -> IO {rw *challenges, rw *forwardFailures, rw *presence, rw *sessions, network, clock, random} (Result HttpError {expiresAt: Int, token: Text})
626+handleVerifyAuth : PubkeyHex -> Text -> Text -> Bool -> Text -> IO {rw *challenges, rw *forwardFailures, rw *presence, rw *sessions, network, clock, random} (Result HttpError {expiresAt: Timestamp, token: Text})
627627handleVerifyAuth = \pubkey challenge signature revokeOthers clientIp -> do
628628 t <- now
629629 let expiry = t + sessionExpiry
@@ -698,7 +698,7 @@ handlePoll = \cursor authorization clientIp -> do
698698-- the wait transaction reads `*messages` and `retry`s until a row matching
699699-- this pubkey/cursor is committed; the timer wins on idle. Either way we
700700-- re-collect at the new wall time, so a timeout returns an empty page.
701−doPoll : {clampedCursor: Int, pubkey: PubkeyHex | a} -> Int<Ms> -> IO {r *messages, clock} {cursor: Int<Ms>, events: [{encryptedBlob: BlobHex}]}
701+doPoll : {clampedCursor: Timestamp, pubkey: PubkeyHex | a} -> Timestamp -> IO {r *messages, clock} {cursor: Timestamp, events: [{encryptedBlob: BlobHex}]}
702702doPoll = \s t -> do
703703 let collectAt = \tnow -> atomic (do
704704 msgs <- *messages