MultiFactorSession DX friction

44 views
Skip to first unread message

David Rogers

unread,
Mar 10, 2023, 5:56:14 PM3/10/23
to Firebase Google Group
I had roughly the following code:

```
const session = multiFactor(creds.user).getSession();
const phoneInfoOptions : PhoneMultiFactorEnrollInfoOptions = {
  phoneNumber: "+15555555555",
  session: session
};
const phoneAuthProvider = new PhoneAuthProvider(myAuth)
await phoneAuthProvider.verifyPhoneNumber(phoneInfoOptions, someRecaptchaVerifier); // <<< throws
```

Throwing the following:

```
FirebaseError: Firebase: Error (auth/internal-error).
    at createErrorInternal (assert.ts:136:55)
    at _assert (assert.ts:167:11)
    at _verifyPhoneNumber (phone.ts:206:9)
    at (my frame)
```

Which wasn't a very helpful error.

It turned out that I was missing an await:

```
const session = await multiFactor(creds.user).getSession();
```

But, `PhoneMultiFactorEnrollInfoOptions["session"]` is declared as

```
export declare interface MultiFactorSession {
}
```

i.e. it is the empty interface, which to my understanding is assignable from any type except undefined or null, so for Typescript, setting `phoneInfoOptions.session` to Promise<MultiFactorSession> is as good as setting it to MultiFactorSession, even though at runtime that doesn't seem to be the case.

I thought it might be good to improve the runtime error, and maybe somehow provide a more restrictive type to enable a compile time error, too.

apez codes

unread,
Mar 11, 2023, 5:59:05 PM3/11/23
to fireba...@googlegroups.com
Try to upgrade your firebase to blaze plan 

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/0ea7866c-2cb5-483c-9851-8501ce9867ffn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages