Skip to content

refactor(server): brand session proof as opaque type#41

Merged
allisson merged 1 commit into
mainfrom
improve
May 15, 2026
Merged

refactor(server): brand session proof as opaque type#41
allisson merged 1 commit into
mainfrom
improve

Conversation

@allisson
Copy link
Copy Markdown
Owner

Replace the raw token string returned by session.issue with a branded ProofOfSession value consumed only by session.attachCookie. The opaque type carries the cookie/row pairing obligation that was previously a comment-only convention.

Defence-in-depth against leaking the token into response bodies: token is non-enumerable and toJSON returns undefined, so spread, Object.keys, and JSON.stringify all drop it — guarding against reply.send({ proof }) and Pino's serialiser. Add an integration regression test asserting the session token never appears in the completion-route bodies.

Replace the raw token string returned by `session.issue` with a
branded `ProofOfSession` value consumed only by `session.attachCookie`.
The opaque type carries the cookie/row pairing obligation that was
previously a comment-only convention.

Defence-in-depth against leaking the token into response bodies:
`token` is non-enumerable and `toJSON` returns undefined, so spread,
Object.keys, and JSON.stringify all drop it — guarding against
`reply.send({ proof })` and Pino's serialiser. Add an integration
regression test asserting the session token never appears in the
completion-route bodies.
@allisson allisson merged commit b35a45f into main May 15, 2026
1 check passed
@allisson allisson deleted the improve branch May 15, 2026 19:36
@allisson allisson mentioned this pull request May 18, 2026
4 tasks
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.

1 participant