Skip to content

feat(auth): add optional jwt parameter to getAuthenticatorAssuranceLevel#1940

Merged
mandarini merged 4 commits into
supabase:masterfrom
7ttp:fix24
Jan 23, 2026
Merged

feat(auth): add optional jwt parameter to getAuthenticatorAssuranceLevel#1940
mandarini merged 4 commits into
supabase:masterfrom
7ttp:fix24

Conversation

@7ttp

@7ttp 7ttp commented Dec 11, 2025

Copy link
Copy Markdown
Contributor

Summary

Adds an optional jwt parameter to mfa.getAuthenticatorAssuranceLevel(), enabling it to work in server side environments like Edge Functions where no session is stored.

Problem

In Edge Functions, getAuthenticatorAssuranceLevel() always returns { currentLevel: null, nextLevel: null, currentAuthenticationMethods: [] } because it relies on getSession() which reads from storage. Edge Functions don't have a stored session, only the JWT from the Authorization header.

Solution

Added an optional jwt parameter following the same pattern as getUser(jwt?):

closes #1677

@7ttp 7ttp requested review from a team as code owners December 11, 2025 11:09

@mandarini mandarini left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@7ttp thanks for this PR. Can you please:

  1. Add some tests for the new JWT code path. Should test:
    - JWT with aal1, no factors returns aal1/aal1
    - JWT with aal1, verified factors returns aal1/aal2
    - Invalid JWT returns error
    - JWT where getUser fails returns error
  2. Fix the documentation mismatch. tsdoc says "rarely uses the network" but the new path calls getUser(jwt) which always makes a network request

After these are done, I will share with auth team to get final ok!

@mandarini mandarini self-assigned this Jan 5, 2026
Comment thread packages/core/auth-js/src/GoTrueClient.ts
@mandarini

Copy link
Copy Markdown
Contributor

@7ttp can you please rebase your PR with latest master? We made some updates in the workflows, and it will be blocked if you don't rebase

@mandarini mandarini left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@7ttp and whoever looks at this PR/addition:

The auth-js library is not optimized for usage in edge functions. I am approving this PR, but with this caveat.

We plan to improve the experience in the next major version

@mandarini mandarini merged commit 26650e5 into supabase:master Jan 23, 2026
21 checks passed
@7ttp 7ttp deleted the fix24 branch March 8, 2026 11:47
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.

getAuthenticatorAssuranceLevel() dont work on edge function

2 participants