fix(templates): repair registration in the Fastify starter - #34
Merged
Conversation
Registering against the scaffolded API returned a 500 with `TypeError: option maxAge is invalid: 300`. The auth server sends the registration response's ttl as the string "300", and the Fastify adapter passes it to a cookie library that requires an integer. The Express starter never showed this: its adapter multiplies the value into milliseconds, which coerces the string. @seamless-auth/core 0.12.1 parses the lifetime before an adapter sees it, so the starter is fixed without waiting on the auth server to send a number. It arrives here through @seamless-auth/fastify 0.3.1. The lockfile is the functional part. @seamless-auth/fastify 0.3.0 already ranged core at ^0.12.0, so a fresh resolve would have picked up the fix, but the committed lockfile pinned core 0.12.0 and that is what a scaffolded project installed. Verified by driving the adapter with the response the auth server actually sends today, a string ttl, through /auth/registration/register. On the committed lockfile that reproduces the reported 500 exactly; after this change it returns 200 with Max-Age=300. Plus npm run validate, npm run build, and npm run lint.
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.
Fixes the 500 you hit registering against the scaffolded Fastify API.
Cause
The auth server sends the registration response's
ttlas the string"300".cookiechecksNumber.isInteger, which a string fails. The Express starter never showed this because its adapter doesmaxAge: seconds * 1000, and the multiply coerces the string to a number.@seamless-auth/core0.12.1 (fells-code/seamless-auth-server#145) parses the lifetime before it reaches an adapter, so the starter is fixed without waiting on the auth server to start sending a number. That server-side fix is fells-code/seamless-auth-api#138, still unreleased, and this template does not need it.What actually fixes it here
The lockfile, not the version range.
@seamless-auth/fastify0.3.0 already ranged core at^0.12.0, so a fresh resolve would have picked up 0.12.1 on its own. But the committed lockfile pinned core 0.12.0, and that is what a scaffolded project installs. I confirmed this: installing@seamless-auth/fastify@0.3.0today still resolves core 0.12.1 and works.The pin moves to
^0.3.1because that is the release carrying the changeset, but the functional change iscore 0.12.0 -> 0.12.1in the lockfile.Verification
Beyond
npm run validate,npm run build, andnpm run lint, I drove the adapter directly with the response the auth server actually sends today (a stringttl) through/auth/registration/register:option maxAge is invalid: 300Set-CookiewithMax-Age=300So the reported failure reproduces exactly on
mainand is gone here.Express starter left alone
It is on
@seamless-auth/express^0.12.0 with core 0.12.0 locked, and it was never broken by this, since its adapter coerced the string. Refreshing its lockfile onto core 0.12.1 is tidy but not a fix, so I left it out rather than widen a bug fix. Happy to do it separately.