Skip to content

Add missing auth API surface (PhoneAuthOptions, AuthResult.credential/additionalUserInfo, setLinkDomain) #68

Description

@nbransby

Summary

Four gaps in this SDK's auth API surface prevent firebase-kotlin-sdk from sharing its
androidMain source with its JVM target for firebase-auth. Closing all four would let
it delete a ~474-line source fork it has carried since 2023.

No working implementations are required — see "Why this is small" below.

Edit: this issue originally listed only the PhoneAuthOptions gap. That alone is
not sufficient to remove the fork — three further gaps in auth.kt were found
afterwards. All four are now listed.

Background

firebase-kotlin-sdk compiles its JVM target by sharing the androidMain source set:

getByName("jvmMain") { kotlin.srcDir("src/androidMain/kotlin") }

10 of its 14 modules do this. firebase-auth used to, but when the Android SDK was
raised, androidMain moved onto APIs this SDK doesn't expose. In f372c418d the
sharing was removed and a parallel src/jvmMain copy was forked.

That fork is 4 files / ~474 lines maintained by hand with no compiler enforcement, and
it has already diverged — multifactor.kt is a byte-identical copy.

The four gaps

1. PhoneAuthOptions does not exist

Android moved phone verification from the instance API to a builder/static API:

PhoneAuthOptions options = PhoneAuthOptions.newBuilder(auth)
    .setPhoneNumber(phoneNumber).setTimeout(timeout, unit)
    .setActivity(activity).setCallbacks(callbacks).build();
PhoneAuthProvider.verifyPhoneNumber(options);

This SDK exposes only the old getInstance(auth).verifyPhoneNumber(...) shape.

Needed: PhoneAuthOptions with static Builder newBuilder(FirebaseAuth), and
Builder methods setPhoneNumber(String), setTimeout(Long, TimeUnit),
setActivity(Activity), setCallbacks(PhoneAuthProvider.OnVerificationStateChangedCallbacks),
setForceResendingToken(PhoneAuthProvider.ForceResendingToken), build().
Plus PhoneAuthProvider.verifyPhoneNumber(PhoneAuthOptions) as a static overload.

2. AuthResult.getCredential() missing

com.google.firebase.auth.AuthResult here is:

public interface AuthResult {
    FirebaseUser getUser();
}

Needed: AuthCredential getCredential().

3. AuthResult.getAdditionalUserInfo() and AdditionalUserInfo missing

Same interface — no getAdditionalUserInfo(). The AdditionalUserInfo type does not
exist in this SDK at all.

Needed: an AdditionalUserInfo type exposing getProviderId(), getUsername(),
getProfile(), isNewUser(), and AuthResult.getAdditionalUserInfo() returning it.

4. ActionCodeSettings.Builder.setLinkDomain(String) missing

The builder here has setDynamicLinkDomain(String) but not the newer
setLinkDomain(String) that Android replaced it with.

Needed: Builder setLinkDomain(String).

Why this is small

The existing PhoneAuthProvider here is already a pure compile-time stub — every method
throws NotImplementedError():

public static PhoneAuthProvider getInstance(FirebaseAuth auth) {
    throw new NotImplementedError();
}

So none of this works on JVM today, and this request does not change that. What's needed
is only that the API shape match the current Android surface, with the same
NotImplementedError bodies (or null returns where a type is simply absent). Behaviour
is identical before and after; the gain is purely that downstream androidMain source
compiles unchanged for JVM.

Outcome

With all four closed, firebase-kotlin-sdk can restore
kotlin.srcDir("src/androidMain/kotlin") for firebase-auth, delete src/jvmMain/
(4 files, ~474 lines), and eliminate the android/jvm drift class of bug for that module.

Partial fixes still help but do not remove the fork — gaps 2, 3 and 4 are all in
auth.kt, so PhoneAuthOptions alone leaves that file unshareable.

Related downstream context: GitLiveApp/firebase-kotlin-sdk#799 touches the same files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions