Move the AuthProvider contract into @wasp.sh/auth-contract and collapse verification into authenticate() - #4718
Closed
FranjoMindek wants to merge 2 commits into
Closed
Conversation
Closed
15 tasks
Deploying wasp-docs-on-main with
|
| Latest commit: |
26128ca
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://35a0308d.wasp-docs-on-main.pages.dev |
| Branch Preview URL: | https://franjo-auth-contract-package.wasp-docs-on-main.pages.dev |
…se verification into authenticate()
FranjoMindek
force-pushed
the
franjo/auth-contract-package
branch
from
August 14, 2026 06:24
6315dc1 to
26128ca
Compare
FranjoMindek
had a problem deploying
to
railway-deploy-test
August 14, 2026 06:40 — with
GitHub Actions
Failure
FranjoMindek
temporarily deployed
to
fly-deploy-test
August 14, 2026 06:40 — with
GitHub Actions
Inactive
@wasp.sh/spec
@wasp.sh/wasp-cli
@wasp.sh/wasp-cli-darwin-arm64-unknown
@wasp.sh/wasp-cli-darwin-x64-unknown
@wasp.sh/wasp-cli-linux-arm64-glibc
@wasp.sh/wasp-cli-linux-x64-glibc
@wasp.sh/wasp-cli-linux-x64-musl
commit: |
Contributor
Author
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.
Description
Stack: PR 4 of the auth provider series, on top of #4716. First of four PRs that turn the provider seam into the real adapter architecture: npm-installable auth adapters, a provider-first spec, and capability-gated codegen. Designed by a multi-agent panel (4 independent designs, judged, synthesized, adversarially verified); every decision below survived a verifier trying to refute it.
This PR makes the provider contract something a third-party npm package can implement, and finalizes the interface before any adapter package exists:
@wasp.sh/auth-contract, a new lib inwaspc/data/Generator/libs/auth-contract/. It rides the existing WaspLib machinery: packed as an npm tarball shipped with the CLI, copied into.wasp/out/libs/, installed into every generated app viafile:deps of the SDK and server. npm hoists it into the app'snode_modules, so generated code, hand-written adapters, and adapter packages all resolve the same copy. (The plan doc proposed@wasp.sh/lib-auth; rejected — argon2 native deps and a react peer have no place in a pure contract.)verifyRequest/verifyCredentialcollapse intoauthenticate(request: Request)— a standard webRequest. Clerk's and Better Auth's SDKs consume one natively, which deletes the per-adaptertoWebRequestshims; Wasp builds it in exactly one place for HTTP, and synthesizes one carrying only theAuthorizationheader for websockets. The contract documents that adapters must authenticate from headers alone (a verifier caught that typing the parameter as Express's request would be a lie on the websocket path).VerifiedSessiongains an optionalclaimspayload — provider-verified profile data (email, name). Both verification passes flagged its absence as the one blocker: without claims, JIT provisioning can never populate a user entity with required columns, and the first request from a new subject is a permanent 401. Claims are recorded asAuthIdentity.providerDataat provisioning; the next PRs feed them touserSignupFields.WaspServerRuntime(withdbProvider— Better Auth's prisma adapter needs the dialect),ServerAdapter(one factory returns provider + route handler, so both share one configured instance), and the client-adapter types.Example adapters are updated to the collapsed method; both now return claims.
One npm behavior worth knowing (cost a debugging session): with an existing
node_modulesand a committed lock,npm installtrusts the lock's stale manifest snapshot for the.wasp/out/sdk/wasppath and silently skips a newly addedfile:dep../run bust-libs-cacheis the repo's own cure; the committed example locks are regenerated here.Type of change
Checklist
I tested my change in a Wasp app to verify that it works as intended.
Runtime-verified at the top of the stack: the wasp-auth example (signup 200, login → sessionId,
/auth/me200, wrong password 401, logout kills the session) and the better-auth example (claims recorded as providerData) both run the collapsedauthenticate()path live. All 932 e2e tests green at this commit.🧪 Tests and apps:
I added unit tests for my change.
The contract package is types plus one predicate; the e2e goldens verify the generated re-export and dependency wiring verbatim, and
tsc --noEmitruns in the package build.(if you fixed a bug) I added a regression test for the bug I fixed.
(if you added/updated a feature) I added/updated e2e tests in
examples/kitchen-sink/e2e-tests.(if you added/updated a feature) I updated the starter templates in
waspc/data/Cli/templates, as needed.(if you added/updated a feature) I updated the example apps in
examples/, as needed.examples/tutorials) I updated the tutorial in the docs (and vice versa).📜 Documentation:
(if you added/updated a feature) I added/updated the documentation in
web/docs/.Still experimental and unreleased; holding docs until the API stops moving, like the rest of the stack.
🆕 Changelog: (if change is more than just code/docs improvement)
waspc/ChangeLog.mdwith a user-friendly description of the change.web/docs/migration-guides/.versioninwaspc/waspc.cabalto reflect the changes I introduced.Holding changelog/version with the rest of the experimental stack.