David Rogers
unread,Mar 10, 2023, 5:56:14 PM3/10/23Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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.