Missing functions in Firebase auth V9

I’m facing a horrible issue with firebase auth. At this point, I’m completely and utterly stumped.

Whenever I try to call user.getIdTokenResult(), I get an error TypeError: undefined is not an object (evaluating 'n.getIdToken').

The user is defined. I log into the console before the function runs, and it always prints out a user. Plus, I’m calling the function in onAuthStateChanged.

What’s even more strange is that it works perfectly on localhost, but once I push to production or even tunnel the domain, it stops working completely.

I have no idea what’s going on.

It looks like this fellow faced the same issue: How to use the getIdToken() auth method in firebase version 9?. No solution, though.

It also looks like it only fails on Safari and iOS.

Code I’m running:

 auth.onAuthStateChanged(async (user) => {
    if (user) {
        console.log('user', user); // prints out a user object
        // Fails here
        const idTokenResult = await user.getIdTokenResult();
...