From c3bfb63f27c116d21ba7b2b87629e36573d4a59e Mon Sep 17 00:00:00 2001 From: Marvin W Date: Sun, 27 Sep 2020 11:40:22 +0200 Subject: [PATCH] Add initial support for Firebase Auth --- build.gradle | 1 + firebase-auth-api/build.gradle | 26 + .../src/main/AndroidManifest.xml | 7 + .../firebase/auth/ActionCodeSettings.aidl | 3 + .../firebase/auth/EmailAuthCredential.aidl | 3 + .../firebase/auth/PhoneAuthCredential.aidl | 3 + .../auth/UserProfileChangeRequest.aidl | 3 + .../internal/ApplyActionCodeAidlRequest.aidl | 3 + .../api/internal/ChangeEmailAidlRequest.aidl | 4 +- .../internal/ChangePasswordAidlRequest.aidl | 3 + .../internal/CheckActionCodeAidlRequest.aidl | 3 + .../ConfirmPasswordResetAidlRequest.aidl | 3 + .../api/internal/CreateAuthUriResponse.aidl | 3 + ...teUserWithEmailAndPasswordAidlRequest.aidl | 3 + .../auth/api/internal/DeleteAidlRequest.aidl | 3 + .../FinalizeMfaEnrollmentAidlRequest.aidl | 3 + .../FinalizeMfaSignInAidlRequest.aidl | 3 + .../internal/GetAccessTokenAidlRequest.aidl | 3 + .../auth/api/internal/GetAccountInfoUser.aidl | 3 + .../GetProvidersForEmailAidlRequest.aidl | 3 + .../auth/api/internal/GetTokenResponse.aidl | 3 + .../api/internal/IFirebaseAuthCallbacks.aidl | 22 + .../api/internal/IFirebaseAuthService.aidl | 108 +++ .../LinkEmailAuthCredentialAidlRequest.aidl | 3 + .../LinkFederatedCredentialAidlRequest.aidl | 3 + .../LinkPhoneAuthCredentialAidlRequest.aidl | 3 + .../auth/api/internal/ReloadAidlRequest.aidl | 3 + .../api/internal/ResetPasswordResponse.aidl | 3 + ...ilVerificationWithSettingsAidlRequest.aidl | 3 + ...etOobConfirmationCodeEmailAidlRequest.aidl | 3 + .../SendVerificationCodeAidlRequest.aidl | 3 + .../internal/SendVerificationCodeRequest.aidl | 3 + .../SetFirebaseUiVersionAidlRequest.aidl | 3 + .../SignInAnonymouslyAidlRequest.aidl | 3 + .../SignInWithCredentialAidlRequest.aidl | 3 + .../SignInWithCustomTokenAidlRequest.aidl | 3 + ...SignInWithEmailAndPasswordAidlRequest.aidl | 3 + .../SignInWithEmailLinkAidlRequest.aidl | 3 + .../SignInWithPhoneNumberAidlRequest.aidl | 3 + ...rtMfaPhoneNumberEnrollmentAidlRequest.aidl | 3 + .../StartMfaPhoneNumberSignInAidlRequest.aidl | 3 + .../auth/api/internal/StringList.aidl | 3 + .../api/internal/UnenrollMfaAidlRequest.aidl | 3 + .../UnlinkEmailCredentialAidlRequest.aidl | 3 + .../UnlinkFederatedCredentialAidlRequest.aidl | 3 + .../internal/UpdateProfileAidlRequest.aidl | 3 + .../api/internal/VerifyAssertionRequest.aidl | 3 + .../VerifyBeforeUpdateEmailAidlRequest.aidl | 3 + .../firebase/auth/ActionCodeSettings.java | 182 +++++ .../google/firebase/auth/AuthCredential.java | 28 + .../firebase/auth/DefaultOAuthCredential.java | 66 ++ .../firebase/auth/EmailAuthCredential.java | 54 ++ .../google/firebase/auth/OAuthCredential.java | 32 + .../firebase/auth/PhoneAuthCredential.java | 64 ++ .../auth/UserProfileChangeRequest.java | 88 +++ .../internal/ApplyActionCodeAidlRequest.java | 12 + .../api/internal/ChangeEmailAidlRequest.java | 12 + .../internal/ChangePasswordAidlRequest.java | 12 + .../internal/CheckActionCodeAidlRequest.java | 12 + .../ConfirmPasswordResetAidlRequest.java | 12 + .../api/internal/CreateAuthUriResponse.java | 27 + ...teUserWithEmailAndPasswordAidlRequest.java | 19 + .../auth/api/internal/DeleteAidlRequest.java | 12 + .../FinalizeMfaEnrollmentAidlRequest.java | 12 + .../FinalizeMfaSignInAidlRequest.java | 12 + .../internal/GetAccessTokenAidlRequest.java | 15 + .../auth/api/internal/GetAccountInfoUser.java | 43 ++ .../GetProvidersForEmailAidlRequest.java | 16 + .../auth/api/internal/GetTokenResponse.java | 44 ++ .../LinkEmailAuthCredentialAidlRequest.java | 18 + .../LinkFederatedCredentialAidlRequest.java | 12 + .../LinkPhoneAuthCredentialAidlRequest.java | 12 + .../firebase/auth/api/internal/MfaInfo.java | 14 + .../auth/api/internal/ProviderUserInfo.java | 27 + .../api/internal/ProviderUserInfoList.java | 19 + .../auth/api/internal/ReloadAidlRequest.java | 14 + .../api/internal/ResetPasswordResponse.java | 20 + ...ilVerificationWithSettingsAidlRequest.java | 18 + ...etOobConfirmationCodeEmailAidlRequest.java | 20 + .../SendVerificationCodeAidlRequest.java | 14 + .../internal/SendVerificationCodeRequest.java | 25 + .../SetFirebaseUiVersionAidlRequest.java | 12 + .../SignInAnonymouslyAidlRequest.java | 14 + .../SignInWithCredentialAidlRequest.java | 12 + .../SignInWithCustomTokenAidlRequest.java | 17 + ...SignInWithEmailAndPasswordAidlRequest.java | 18 + .../SignInWithEmailLinkAidlRequest.java | 12 + .../SignInWithPhoneNumberAidlRequest.java | 19 + ...rtMfaPhoneNumberEnrollmentAidlRequest.java | 12 + .../StartMfaPhoneNumberSignInAidlRequest.java | 12 + .../auth/api/internal/StringList.java | 19 + .../api/internal/UnenrollMfaAidlRequest.java | 12 + .../UnlinkEmailCredentialAidlRequest.java | 12 + .../UnlinkFederatedCredentialAidlRequest.java | 12 + .../internal/UpdateProfileAidlRequest.java | 18 + .../api/internal/VerifyAssertionRequest.java | 12 + .../VerifyBeforeUpdateEmailAidlRequest.java | 12 + .../microg/gms/firebase/auth/Constants.java | 11 + firebase-auth-core/build.gradle | 46 ++ .../src/main/AndroidManifest.xml | 25 + .../src/main/assets/recaptcha.html | 54 ++ .../gms/firebase/auth/FirebaseAuthService.kt | 649 ++++++++++++++++++ .../firebase/auth/IdentityToolkitClient.kt | 139 ++++ .../gms/firebase/auth/ReCaptchaActivity.kt | 103 +++ .../gms/firebase/auth/ReCaptchaOverlay.kt | 119 ++++ .../main/res/layout/activity_recaptcha.xml | 19 + .../res/values/{layout.xml => themes.xml} | 5 + play-services-base-core/build.gradle | 1 + .../org/microg/gms/common/GmsService.java | 1 + play-services-core/build.gradle | 1 + .../src/main/AndroidManifest.xml | 6 - .../android/gms/auth/FirebaseAuthService.java | 29 - .../firebase/FirebaseAuthServiceImpl.java | 41 -- .../clearcut/ClearcutLoggerServiceImpl.java | 5 +- play-services-location-core/build.gradle | 2 + settings.gradle | 7 +- 116 files changed, 2687 insertions(+), 82 deletions(-) create mode 100644 firebase-auth-api/build.gradle create mode 100644 firebase-auth-api/src/main/AndroidManifest.xml create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/ActionCodeSettings.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/EmailAuthCredential.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/PhoneAuthCredential.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/UserProfileChangeRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/ApplyActionCodeAidlRequest.aidl rename play-services-api/src/main/aidl/com/google/firebase/auth/api/internal/IFirebaseAuthService.aidl => firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/ChangeEmailAidlRequest.aidl (57%) create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/ChangePasswordAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/CheckActionCodeAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/ConfirmPasswordResetAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/CreateAuthUriResponse.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/CreateUserWithEmailAndPasswordAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/DeleteAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/FinalizeMfaEnrollmentAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/FinalizeMfaSignInAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/GetAccessTokenAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/GetAccountInfoUser.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/GetProvidersForEmailAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/GetTokenResponse.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/IFirebaseAuthCallbacks.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/IFirebaseAuthService.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/LinkEmailAuthCredentialAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/LinkFederatedCredentialAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/LinkPhoneAuthCredentialAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/ReloadAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/ResetPasswordResponse.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SendEmailVerificationWithSettingsAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SendGetOobConfirmationCodeEmailAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SendVerificationCodeAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SendVerificationCodeRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SetFirebaseUiVersionAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SignInAnonymouslyAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SignInWithCredentialAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SignInWithCustomTokenAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SignInWithEmailAndPasswordAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SignInWithEmailLinkAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SignInWithPhoneNumberAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/StartMfaPhoneNumberEnrollmentAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/StartMfaPhoneNumberSignInAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/StringList.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/UnenrollMfaAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/UnlinkEmailCredentialAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/UnlinkFederatedCredentialAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/UpdateProfileAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/VerifyAssertionRequest.aidl create mode 100644 firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/VerifyBeforeUpdateEmailAidlRequest.aidl create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/ActionCodeSettings.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/AuthCredential.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/DefaultOAuthCredential.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/EmailAuthCredential.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/OAuthCredential.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/PhoneAuthCredential.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/UserProfileChangeRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ApplyActionCodeAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ChangeEmailAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ChangePasswordAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/CheckActionCodeAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ConfirmPasswordResetAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/CreateAuthUriResponse.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/CreateUserWithEmailAndPasswordAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/DeleteAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/FinalizeMfaEnrollmentAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/FinalizeMfaSignInAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/GetAccessTokenAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/GetAccountInfoUser.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/GetProvidersForEmailAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/GetTokenResponse.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/LinkEmailAuthCredentialAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/LinkFederatedCredentialAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/LinkPhoneAuthCredentialAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/MfaInfo.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ProviderUserInfo.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ProviderUserInfoList.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ReloadAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ResetPasswordResponse.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SendEmailVerificationWithSettingsAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SendGetOobConfirmationCodeEmailAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SendVerificationCodeAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SendVerificationCodeRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SetFirebaseUiVersionAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SignInAnonymouslyAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SignInWithCredentialAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SignInWithCustomTokenAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SignInWithEmailAndPasswordAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SignInWithEmailLinkAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SignInWithPhoneNumberAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/StartMfaPhoneNumberEnrollmentAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/StartMfaPhoneNumberSignInAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/StringList.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/UnenrollMfaAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/UnlinkEmailCredentialAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/UnlinkFederatedCredentialAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/UpdateProfileAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/VerifyAssertionRequest.java create mode 100644 firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/VerifyBeforeUpdateEmailAidlRequest.java create mode 100644 firebase-auth-api/src/main/java/org/microg/gms/firebase/auth/Constants.java create mode 100644 firebase-auth-core/build.gradle create mode 100644 firebase-auth-core/src/main/AndroidManifest.xml create mode 100644 firebase-auth-core/src/main/assets/recaptcha.html create mode 100644 firebase-auth-core/src/main/kotlin/org/microg/gms/firebase/auth/FirebaseAuthService.kt create mode 100644 firebase-auth-core/src/main/kotlin/org/microg/gms/firebase/auth/IdentityToolkitClient.kt create mode 100644 firebase-auth-core/src/main/kotlin/org/microg/gms/firebase/auth/ReCaptchaActivity.kt create mode 100644 firebase-auth-core/src/main/kotlin/org/microg/gms/firebase/auth/ReCaptchaOverlay.kt create mode 100644 firebase-auth-core/src/main/res/layout/activity_recaptcha.xml rename play-services-base-core-ui/src/main/res/values/{layout.xml => themes.xml} (66%) delete mode 100644 play-services-core/src/main/java/com/google/android/gms/auth/FirebaseAuthService.java delete mode 100644 play-services-core/src/main/java/org/microg/gms/auth/firebase/FirebaseAuthServiceImpl.java diff --git a/build.gradle b/build.gradle index de25a6ff..ffdf9877 100644 --- a/build.gradle +++ b/build.gradle @@ -25,6 +25,7 @@ buildscript { ext.supportLibraryVersion = '28.0.0' ext.slf4jVersion = '1.7.25' + ext.volleyVersion = '1.1.1' ext.wireVersion = '3.2.2' ext.androidBuildGradleVersion = '3.6.3' diff --git a/firebase-auth-api/build.gradle b/firebase-auth-api/build.gradle new file mode 100644 index 00000000..bb8662f8 --- /dev/null +++ b/firebase-auth-api/build.gradle @@ -0,0 +1,26 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +apply plugin: 'com.android.library' + +android { + compileSdkVersion androidCompileSdk + buildToolsVersion "$androidBuildVersionTools" + + defaultConfig { + versionName version + minSdkVersion androidMinSdk + targetSdkVersion androidTargetSdk + } + + compileOptions { + sourceCompatibility = 1.8 + targetCompatibility = 1.8 + } +} + +dependencies { + api project(':play-services-basement') +} diff --git a/firebase-auth-api/src/main/AndroidManifest.xml b/firebase-auth-api/src/main/AndroidManifest.xml new file mode 100644 index 00000000..95249c36 --- /dev/null +++ b/firebase-auth-api/src/main/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/ActionCodeSettings.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/ActionCodeSettings.aidl new file mode 100644 index 00000000..adedd192 --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/ActionCodeSettings.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth; + +parcelable ActionCodeSettings; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/EmailAuthCredential.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/EmailAuthCredential.aidl new file mode 100644 index 00000000..20cabbd4 --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/EmailAuthCredential.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth; + +parcelable EmailAuthCredential; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/PhoneAuthCredential.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/PhoneAuthCredential.aidl new file mode 100644 index 00000000..b3d6abbc --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/PhoneAuthCredential.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth; + +parcelable PhoneAuthCredential; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/UserProfileChangeRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/UserProfileChangeRequest.aidl new file mode 100644 index 00000000..123af808 --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/UserProfileChangeRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth; + +parcelable UserProfileChangeRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/ApplyActionCodeAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/ApplyActionCodeAidlRequest.aidl new file mode 100644 index 00000000..9e0520ba --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/ApplyActionCodeAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable ApplyActionCodeAidlRequest; diff --git a/play-services-api/src/main/aidl/com/google/firebase/auth/api/internal/IFirebaseAuthService.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/ChangeEmailAidlRequest.aidl similarity index 57% rename from play-services-api/src/main/aidl/com/google/firebase/auth/api/internal/IFirebaseAuthService.aidl rename to firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/ChangeEmailAidlRequest.aidl index 6269896b..e95043ad 100644 --- a/play-services-api/src/main/aidl/com/google/firebase/auth/api/internal/IFirebaseAuthService.aidl +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/ChangeEmailAidlRequest.aidl @@ -1,5 +1,3 @@ package com.google.firebase.auth.api.internal; -interface IFirebaseAuthService { - -} \ No newline at end of file +parcelable ChangeEmailAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/ChangePasswordAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/ChangePasswordAidlRequest.aidl new file mode 100644 index 00000000..55457b48 --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/ChangePasswordAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable ChangePasswordAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/CheckActionCodeAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/CheckActionCodeAidlRequest.aidl new file mode 100644 index 00000000..6d4afa8f --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/CheckActionCodeAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable CheckActionCodeAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/ConfirmPasswordResetAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/ConfirmPasswordResetAidlRequest.aidl new file mode 100644 index 00000000..12f79de9 --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/ConfirmPasswordResetAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable ConfirmPasswordResetAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/CreateAuthUriResponse.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/CreateAuthUriResponse.aidl new file mode 100644 index 00000000..fae42151 --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/CreateAuthUriResponse.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable CreateAuthUriResponse; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/CreateUserWithEmailAndPasswordAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/CreateUserWithEmailAndPasswordAidlRequest.aidl new file mode 100644 index 00000000..9191617f --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/CreateUserWithEmailAndPasswordAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable CreateUserWithEmailAndPasswordAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/DeleteAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/DeleteAidlRequest.aidl new file mode 100644 index 00000000..d45bda0a --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/DeleteAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable DeleteAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/FinalizeMfaEnrollmentAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/FinalizeMfaEnrollmentAidlRequest.aidl new file mode 100644 index 00000000..50bfa3b5 --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/FinalizeMfaEnrollmentAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable FinalizeMfaEnrollmentAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/FinalizeMfaSignInAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/FinalizeMfaSignInAidlRequest.aidl new file mode 100644 index 00000000..2453bd6f --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/FinalizeMfaSignInAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable FinalizeMfaSignInAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/GetAccessTokenAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/GetAccessTokenAidlRequest.aidl new file mode 100644 index 00000000..cc44192e --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/GetAccessTokenAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable GetAccessTokenAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/GetAccountInfoUser.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/GetAccountInfoUser.aidl new file mode 100644 index 00000000..50c33169 --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/GetAccountInfoUser.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable GetAccountInfoUser; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/GetProvidersForEmailAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/GetProvidersForEmailAidlRequest.aidl new file mode 100644 index 00000000..0760f596 --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/GetProvidersForEmailAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable GetProvidersForEmailAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/GetTokenResponse.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/GetTokenResponse.aidl new file mode 100644 index 00000000..b6838f6d --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/GetTokenResponse.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable GetTokenResponse; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/IFirebaseAuthCallbacks.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/IFirebaseAuthCallbacks.aidl new file mode 100644 index 00000000..9c285521 --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/IFirebaseAuthCallbacks.aidl @@ -0,0 +1,22 @@ +package com.google.firebase.auth.api.internal; + +import com.google.android.gms.common.api.Status; +import com.google.firebase.auth.PhoneAuthCredential; +import com.google.firebase.auth.api.internal.CreateAuthUriResponse; +import com.google.firebase.auth.api.internal.GetAccountInfoUser; +import com.google.firebase.auth.api.internal.GetTokenResponse; +import com.google.firebase.auth.api.internal.ResetPasswordResponse; + +interface IFirebaseAuthCallbacks { + void onGetTokenResponse(in GetTokenResponse response) = 0; + void onGetTokenResponseAndUser(in GetTokenResponse response, in GetAccountInfoUser user) = 1; + void onCreateAuthUriResponse(in CreateAuthUriResponse response) = 2; + void onResetPasswordResponse(in ResetPasswordResponse response) = 3; + void onFailure(in Status status) = 4; + void onDeleteAccountResponse() = 5; + void onEmailVerificationResponse() = 6; + + void onSendVerificationCodeResponse(String sessionInfo) = 8; + void onVerificationCompletedResponse(in PhoneAuthCredential credential) = 9; + void onVerificationAutoTimeOut(String sessionInfo) = 10; +} diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/IFirebaseAuthService.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/IFirebaseAuthService.aidl new file mode 100644 index 00000000..07144924 --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/IFirebaseAuthService.aidl @@ -0,0 +1,108 @@ +package com.google.firebase.auth.api.internal; + +import com.google.firebase.auth.api.internal.ApplyActionCodeAidlRequest; +import com.google.firebase.auth.api.internal.ChangeEmailAidlRequest; +import com.google.firebase.auth.api.internal.ChangePasswordAidlRequest; +import com.google.firebase.auth.api.internal.CheckActionCodeAidlRequest; +import com.google.firebase.auth.api.internal.ConfirmPasswordResetAidlRequest; +import com.google.firebase.auth.api.internal.CreateUserWithEmailAndPasswordAidlRequest; +import com.google.firebase.auth.api.internal.DeleteAidlRequest; +import com.google.firebase.auth.api.internal.FinalizeMfaEnrollmentAidlRequest; +import com.google.firebase.auth.api.internal.FinalizeMfaSignInAidlRequest; +import com.google.firebase.auth.api.internal.GetAccessTokenAidlRequest; +import com.google.firebase.auth.api.internal.GetProvidersForEmailAidlRequest; +import com.google.firebase.auth.api.internal.IFirebaseAuthCallbacks; +import com.google.firebase.auth.api.internal.LinkEmailAuthCredentialAidlRequest; +import com.google.firebase.auth.api.internal.LinkFederatedCredentialAidlRequest; +import com.google.firebase.auth.api.internal.LinkPhoneAuthCredentialAidlRequest; +import com.google.firebase.auth.api.internal.ReloadAidlRequest; +import com.google.firebase.auth.api.internal.SendEmailVerificationWithSettingsAidlRequest; +import com.google.firebase.auth.api.internal.SendGetOobConfirmationCodeEmailAidlRequest; +import com.google.firebase.auth.api.internal.SendVerificationCodeAidlRequest; +import com.google.firebase.auth.api.internal.SendVerificationCodeRequest; +import com.google.firebase.auth.api.internal.SetFirebaseUiVersionAidlRequest; +import com.google.firebase.auth.api.internal.SignInAnonymouslyAidlRequest; +import com.google.firebase.auth.api.internal.SignInWithCredentialAidlRequest; +import com.google.firebase.auth.api.internal.SignInWithCustomTokenAidlRequest; +import com.google.firebase.auth.api.internal.SignInWithEmailAndPasswordAidlRequest; +import com.google.firebase.auth.api.internal.SignInWithEmailLinkAidlRequest; +import com.google.firebase.auth.api.internal.SignInWithPhoneNumberAidlRequest; +import com.google.firebase.auth.api.internal.StartMfaPhoneNumberEnrollmentAidlRequest; +import com.google.firebase.auth.api.internal.StartMfaPhoneNumberSignInAidlRequest; +import com.google.firebase.auth.api.internal.UnenrollMfaAidlRequest; +import com.google.firebase.auth.api.internal.UnlinkEmailCredentialAidlRequest; +import com.google.firebase.auth.api.internal.UnlinkFederatedCredentialAidlRequest; +import com.google.firebase.auth.api.internal.UpdateProfileAidlRequest; +import com.google.firebase.auth.api.internal.VerifyAssertionRequest; +import com.google.firebase.auth.api.internal.VerifyBeforeUpdateEmailAidlRequest; +import com.google.firebase.auth.ActionCodeSettings; +import com.google.firebase.auth.EmailAuthCredential; +import com.google.firebase.auth.PhoneAuthCredential; +import com.google.firebase.auth.UserProfileChangeRequest; + +interface IFirebaseAuthService { + void getAccessTokenCompat(String refreshToken, IFirebaseAuthCallbacks callbacks) = 0; + void signInWithCustomTokenCompat(String token, IFirebaseAuthCallbacks callbacks) = 1; + void signInWithCredentialCompat(in VerifyAssertionRequest verifyAssertionRequest, IFirebaseAuthCallbacks callbacks) = 2; + void updateProfileCompat(String cachedState, in UserProfileChangeRequest userProfileChangeRequest, IFirebaseAuthCallbacks callbacks) = 3; + void changeEmailCompat(String cachedState, String email, IFirebaseAuthCallbacks callbacks) = 4; + void changePasswordCompat(String cachedState, String password, IFirebaseAuthCallbacks callbacks) = 5; + void createUserWithEmailAndPasswordCompat(String email, String password, IFirebaseAuthCallbacks callbacks) = 6; + void signInWithEmailAndPasswordCompat(String email, String password, IFirebaseAuthCallbacks callbacks) = 7; + void getProvidersForEmailCompat(String email, IFirebaseAuthCallbacks callbacks) = 8; + + void linkEmailAuthCredentialCompat(String email, String password, String cachedState, IFirebaseAuthCallbacks callbacks) = 10; + void linkFederatedCredentialCompat(String cachedState, in VerifyAssertionRequest verifyAssertionRequest, IFirebaseAuthCallbacks callbacks) = 11; + void unlinkEmailCredentialCompat(String cachedState, IFirebaseAuthCallbacks callbacks) = 12; + void unlinkFederatedCredentialCompat(String provider, String cachedState, IFirebaseAuthCallbacks callbacks) = 13; + void reloadCompat(String cachedState, IFirebaseAuthCallbacks callbacks) = 14; + void signInAnonymouslyCompat(IFirebaseAuthCallbacks callbacks) = 15; + void deleteCompat(String cachedState, IFirebaseAuthCallbacks callbacks) = 16; + void checkActionCodeCompat(String code, IFirebaseAuthCallbacks callbacks) = 18; + void applyActionCodeCompat(String code, IFirebaseAuthCallbacks callbacks) = 19; + void confirmPasswordResetCompat(String code, String newPassword, IFirebaseAuthCallbacks callbacks) = 20; + void sendVerificationCodeCompat(in SendVerificationCodeRequest request, IFirebaseAuthCallbacks callbacks) = 21; + void signInWithPhoneNumberCompat(in PhoneAuthCredential credential, IFirebaseAuthCallbacks callbacks) = 22; + void linkPhoneAuthCredentialCompat(String cachedState, in PhoneAuthCredential credential, IFirebaseAuthCallbacks callbacks) = 23; + + void sendEmailVerificationCompat(String token, in ActionCodeSettings actionCodeSettings, IFirebaseAuthCallbacks callbacks) = 25; + void setFirebaseUIVersionCompat(String firebaseUiVersion, IFirebaseAuthCallbacks callbacks) = 26; + void sendGetOobConfirmationCodeEmailCompat(String email, in ActionCodeSettings actionCodeSettings, IFirebaseAuthCallbacks callbacks) = 27; + void signInWithEmailLinkCompat(in EmailAuthCredential credential, IFirebaseAuthCallbacks callbacks) = 28; + + void getAccessToken(in GetAccessTokenAidlRequest request, IFirebaseAuthCallbacks callbacks) = 100; + void signInWithCustomToken(in SignInWithCustomTokenAidlRequest request, IFirebaseAuthCallbacks callbacks) = 101; + void signInWithCredential(in SignInWithCredentialAidlRequest request, IFirebaseAuthCallbacks callbacks) = 102; + void updateProfile(in UpdateProfileAidlRequest request, IFirebaseAuthCallbacks callbacks) = 103; + void changeEmail(in ChangeEmailAidlRequest request, IFirebaseAuthCallbacks callbacks) = 104; + void changePassword(in ChangePasswordAidlRequest request, IFirebaseAuthCallbacks callbacks) = 105; + void createUserWithEmailAndPassword(in CreateUserWithEmailAndPasswordAidlRequest request, IFirebaseAuthCallbacks callbacks) = 106; + void signInWithEmailAndPassword(in SignInWithEmailAndPasswordAidlRequest request, IFirebaseAuthCallbacks callbacks) = 107; + void getProvidersForEmail(in GetProvidersForEmailAidlRequest request, IFirebaseAuthCallbacks callbacks) = 108; + + void linkEmailAuthCredential(in LinkEmailAuthCredentialAidlRequest request, IFirebaseAuthCallbacks callbacks) = 110; + void linkFederatedCredential(in LinkFederatedCredentialAidlRequest request, IFirebaseAuthCallbacks callbacks) = 111; + void unlinkEmailCredential(in UnlinkEmailCredentialAidlRequest request, IFirebaseAuthCallbacks callbacks) = 112; + void unlinkFederatedCredential(in UnlinkFederatedCredentialAidlRequest request, IFirebaseAuthCallbacks callbacks) = 113; + void reload(in ReloadAidlRequest request, IFirebaseAuthCallbacks callbacks) = 114; + void signInAnonymously(in SignInAnonymouslyAidlRequest request, IFirebaseAuthCallbacks callbacks) = 115; + void delete(in DeleteAidlRequest request, IFirebaseAuthCallbacks callbacks) = 116; + void checkActionCode(in CheckActionCodeAidlRequest request, IFirebaseAuthCallbacks callbacks) = 118; + void applyActionCode(in ApplyActionCodeAidlRequest request, IFirebaseAuthCallbacks callbacks) = 119; + void confirmPasswordReset(in ConfirmPasswordResetAidlRequest request, IFirebaseAuthCallbacks callbacks) = 120; + void sendVerificationCode(in SendVerificationCodeAidlRequest request, IFirebaseAuthCallbacks callbacks) = 121; + void signInWithPhoneNumber(in SignInWithPhoneNumberAidlRequest request, IFirebaseAuthCallbacks callbacks) = 122; + void linkPhoneAuthCredential(in LinkPhoneAuthCredentialAidlRequest request, IFirebaseAuthCallbacks callbacks) = 123; + + void sendEmailVerification(in SendEmailVerificationWithSettingsAidlRequest request, IFirebaseAuthCallbacks callbacks) = 125; + void setFirebaseUiVersion(in SetFirebaseUiVersionAidlRequest request, IFirebaseAuthCallbacks callbacks) = 126; + void sendGetOobConfirmationCodeEmail(in SendGetOobConfirmationCodeEmailAidlRequest request, IFirebaseAuthCallbacks callbacks) = 127; + void signInWithEmailLink(in SignInWithEmailLinkAidlRequest request, IFirebaseAuthCallbacks callbacks) = 128; + + void startMfaEnrollmentWithPhoneNumber(in StartMfaPhoneNumberEnrollmentAidlRequest request, IFirebaseAuthCallbacks callbacks) = 129; + void unenrollMfa(in UnenrollMfaAidlRequest request, IFirebaseAuthCallbacks callbacks) = 130; + void finalizeMfaEnrollment(in FinalizeMfaEnrollmentAidlRequest request, IFirebaseAuthCallbacks callbacks) = 131; + void startMfaSignInWithPhoneNumber(in StartMfaPhoneNumberSignInAidlRequest request, IFirebaseAuthCallbacks callbacks) = 132; + void finalizeMfaSignIn(in FinalizeMfaSignInAidlRequest request, IFirebaseAuthCallbacks callbacks) = 133; + void verifyBeforeUpdateEmail(in VerifyBeforeUpdateEmailAidlRequest request, IFirebaseAuthCallbacks callbacks) = 134; +} diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/LinkEmailAuthCredentialAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/LinkEmailAuthCredentialAidlRequest.aidl new file mode 100644 index 00000000..bee0011b --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/LinkEmailAuthCredentialAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable LinkEmailAuthCredentialAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/LinkFederatedCredentialAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/LinkFederatedCredentialAidlRequest.aidl new file mode 100644 index 00000000..3894901d --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/LinkFederatedCredentialAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable LinkFederatedCredentialAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/LinkPhoneAuthCredentialAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/LinkPhoneAuthCredentialAidlRequest.aidl new file mode 100644 index 00000000..62caaf6a --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/LinkPhoneAuthCredentialAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable LinkPhoneAuthCredentialAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/ReloadAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/ReloadAidlRequest.aidl new file mode 100644 index 00000000..5057e2e4 --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/ReloadAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable ReloadAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/ResetPasswordResponse.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/ResetPasswordResponse.aidl new file mode 100644 index 00000000..572587f0 --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/ResetPasswordResponse.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable ResetPasswordResponse; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SendEmailVerificationWithSettingsAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SendEmailVerificationWithSettingsAidlRequest.aidl new file mode 100644 index 00000000..6db47c5b --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SendEmailVerificationWithSettingsAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable SendEmailVerificationWithSettingsAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SendGetOobConfirmationCodeEmailAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SendGetOobConfirmationCodeEmailAidlRequest.aidl new file mode 100644 index 00000000..5e1e5190 --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SendGetOobConfirmationCodeEmailAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable SendGetOobConfirmationCodeEmailAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SendVerificationCodeAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SendVerificationCodeAidlRequest.aidl new file mode 100644 index 00000000..21b49716 --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SendVerificationCodeAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable SendVerificationCodeAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SendVerificationCodeRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SendVerificationCodeRequest.aidl new file mode 100644 index 00000000..3f797f58 --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SendVerificationCodeRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable SendVerificationCodeRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SetFirebaseUiVersionAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SetFirebaseUiVersionAidlRequest.aidl new file mode 100644 index 00000000..39ff41a0 --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SetFirebaseUiVersionAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable SetFirebaseUiVersionAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SignInAnonymouslyAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SignInAnonymouslyAidlRequest.aidl new file mode 100644 index 00000000..2b4c21fb --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SignInAnonymouslyAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable SignInAnonymouslyAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SignInWithCredentialAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SignInWithCredentialAidlRequest.aidl new file mode 100644 index 00000000..acda7af4 --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SignInWithCredentialAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable SignInWithCredentialAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SignInWithCustomTokenAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SignInWithCustomTokenAidlRequest.aidl new file mode 100644 index 00000000..047489e0 --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SignInWithCustomTokenAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable SignInWithCustomTokenAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SignInWithEmailAndPasswordAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SignInWithEmailAndPasswordAidlRequest.aidl new file mode 100644 index 00000000..77a277de --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SignInWithEmailAndPasswordAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable SignInWithEmailAndPasswordAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SignInWithEmailLinkAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SignInWithEmailLinkAidlRequest.aidl new file mode 100644 index 00000000..1bb2d32d --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SignInWithEmailLinkAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable SignInWithEmailLinkAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SignInWithPhoneNumberAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SignInWithPhoneNumberAidlRequest.aidl new file mode 100644 index 00000000..270d3420 --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/SignInWithPhoneNumberAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable SignInWithPhoneNumberAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/StartMfaPhoneNumberEnrollmentAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/StartMfaPhoneNumberEnrollmentAidlRequest.aidl new file mode 100644 index 00000000..630a4c93 --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/StartMfaPhoneNumberEnrollmentAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable StartMfaPhoneNumberEnrollmentAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/StartMfaPhoneNumberSignInAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/StartMfaPhoneNumberSignInAidlRequest.aidl new file mode 100644 index 00000000..65c80630 --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/StartMfaPhoneNumberSignInAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable StartMfaPhoneNumberSignInAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/StringList.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/StringList.aidl new file mode 100644 index 00000000..62446017 --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/StringList.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable StringList; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/UnenrollMfaAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/UnenrollMfaAidlRequest.aidl new file mode 100644 index 00000000..5ce470b8 --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/UnenrollMfaAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable UnenrollMfaAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/UnlinkEmailCredentialAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/UnlinkEmailCredentialAidlRequest.aidl new file mode 100644 index 00000000..735a3195 --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/UnlinkEmailCredentialAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable UnlinkEmailCredentialAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/UnlinkFederatedCredentialAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/UnlinkFederatedCredentialAidlRequest.aidl new file mode 100644 index 00000000..eb473913 --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/UnlinkFederatedCredentialAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable UnlinkFederatedCredentialAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/UpdateProfileAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/UpdateProfileAidlRequest.aidl new file mode 100644 index 00000000..db6603cf --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/UpdateProfileAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable UpdateProfileAidlRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/VerifyAssertionRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/VerifyAssertionRequest.aidl new file mode 100644 index 00000000..7f4787ff --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/VerifyAssertionRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable VerifyAssertionRequest; diff --git a/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/VerifyBeforeUpdateEmailAidlRequest.aidl b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/VerifyBeforeUpdateEmailAidlRequest.aidl new file mode 100644 index 00000000..79298927 --- /dev/null +++ b/firebase-auth-api/src/main/aidl/com/google/firebase/auth/api/internal/VerifyBeforeUpdateEmailAidlRequest.aidl @@ -0,0 +1,3 @@ +package com.google.firebase.auth.api.internal; + +parcelable VerifyBeforeUpdateEmailAidlRequest; diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/ActionCodeSettings.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/ActionCodeSettings.java new file mode 100644 index 00000000..df07dd64 --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/ActionCodeSettings.java @@ -0,0 +1,182 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + * Notice: Portions of this file are reproduced from work created and shared by Google and used + * according to terms described in the Creative Commons 4.0 Attribution License. + * See https://developers.google.com/readme/policies for details. + */ + +package com.google.firebase.auth; + +import org.microg.gms.common.PublicApi; +import org.microg.safeparcel.AutoSafeParcelable; + +/** + * Structure that contains the required continue/state URL with optional Android and iOS bundle identifiers. + * The stateUrl used to initialize this class is the link/deep link/fallback url used while constructing the Firebase dynamic link. + */ +@PublicApi +public class ActionCodeSettings extends AutoSafeParcelable { + @Field(1) + @PublicApi(exclude = true) + public String url; + @Field(2) + @PublicApi(exclude = true) + public String iOSBundle; + @Field(3) + @PublicApi(exclude = true) + public String iOSAppStoreId; + @Field(4) + @PublicApi(exclude = true) + public String androidPackageName; + @Field(5) + @PublicApi(exclude = true) + public boolean androidInstallApp; + @Field(6) + @PublicApi(exclude = true) + public String androidMinimumVersion; + @Field(7) + @PublicApi(exclude = true) + public boolean handleCodeInApp; + @Field(8) + @PublicApi(exclude = true) + public String localeHeader; + @Field(9) + @PublicApi(exclude = true) + public int requestType; + @Field(10) + @PublicApi(exclude = true) + public String dynamicLinkDomain; + + private ActionCodeSettings() { + } + + /** + * @return whether the oob code should be handled by the app. See {@link Builder#setHandleCodeInApp(boolean)} + */ + public boolean canHandleCodeInApp() { + return handleCodeInApp; + } + + /** + * @return the preference for whether to attempt to install the app if it is not present. See {@link Builder#setAndroidPackageName(String, boolean, String)} + */ + public boolean getAndroidInstallApp() { + return androidInstallApp; + } + + /** + * @return the minimum Android app version. See {@link Builder#setAndroidPackageName(String, boolean, String)} + */ + public String getAndroidMinimumVersion() { + return androidMinimumVersion; + } + + /** + * @return the Android Package Name. See {@link Builder#setAndroidPackageName(String, boolean, String)} + */ + public String getAndroidPackageName() { + return androidPackageName; + } + + /** + * @return the iOS Bundle. See {@link Builder#setIOSBundleId(String)} + */ + public String getIOSBundle() { + return iOSBundle; + } + + /** + * @return the URL. See {@link Builder#setUrl(String)} + */ + public String getUrl() { + return url; + } + + /** + * @return a new instance of {@link ActionCodeSettings.Builder}. + */ + public static Builder newBuilder() { + return new Builder(); + } + + /** + * A Builder class for {@link ActionCodeSettings}. Get an instance of this Builder using {@link #newBuilder()}. + */ + public static class Builder { + private String url; + private String iOSBundleId; + private String androidPackageName; + private boolean androidInstallApp; + private String androidMinimumVersion; + private boolean canHandleCodeInApp; + private String dynamicLinkDomain; + + public ActionCodeSettings build() { + ActionCodeSettings settings = new ActionCodeSettings(); + settings.url = url; + settings.iOSBundle = iOSBundleId; + settings.androidPackageName = androidPackageName; + settings.androidInstallApp = androidInstallApp; + settings.handleCodeInApp = canHandleCodeInApp; + settings.dynamicLinkDomain = dynamicLinkDomain; + return settings; + } + + /** + * Sets the Android package name and returns the current builder instance. + * If {@code installIfNotAvailable} is set to true and the link is opened on an android device, it will try to install the app if not already available. + * Otherwise the web URL is used. + *

+ * A minimum version string is also available. If the installed app is an older version, the user is taken to the Play Store to upgrade the app. + */ + public Builder setAndroidPackageName(String androidPackageName, boolean installIfNotAvailable, String minimumVersion) { + this.androidPackageName = androidPackageName; + this.androidInstallApp = installIfNotAvailable; + this.androidMinimumVersion = minimumVersion; + return this; + } + + /** + * Sets the optional FDL domain, overriding the default FDL domain that would be used. + * Must be one of the 5 domains configured in the Firebase console. + */ + public Builder setDynamicLinkDomain(String dynamicLinkDomain) { + this.dynamicLinkDomain = dynamicLinkDomain; + return this; + } + + /** + * The default is false. When set to true, the action code link will be sent as a universal link and will be open by the app if installed. + * In the false case, the code will be sent to the web widget first and then on continue will redirect to the app if installed. + */ + public Builder setHandleCodeInApp(boolean status) { + this.canHandleCodeInApp = status; + return this; + } + + /** + * To be used if the email link that is sent might be opened on an iOS device. + *

+ * Sets the iOS bundle Id and returns the current {@link ActionCodeSettings.Builder} instance. + */ + public Builder setIOSBundleId(String iOSBundleId) { + this.iOSBundleId = iOSBundleId; + return this; + } + + /** + * Sets the URL, which has different meanings in different contexts. For email actions, this is the state/continue URL. + * When the app is not installed, this is the web continue URL with any developer provided state appended (the continueURL query parameter). + * When the app is installed, this is contained in the Firebase dynamic link payload. + * In the case where the code is sent directly to the app and the app is installed, this is the continueURL query parameter in the dynamic link payload. + * Otherwise, when the code is handled by the widget itself, it is the payload itself. + */ + public Builder setUrl(String url) { + this.url = url; + return this; + } + } + + public static final Creator CREATOR = new AutoCreator<>(ActionCodeSettings.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/AuthCredential.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/AuthCredential.java new file mode 100644 index 00000000..bf3b7e6e --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/AuthCredential.java @@ -0,0 +1,28 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + * Notice: Portions of this file are reproduced from work created and shared by Google and used + * according to terms described in the Creative Commons 4.0 Attribution License. + * See https://developers.google.com/readme/policies for details. + */ + +package com.google.firebase.auth; + +import org.microg.gms.common.PublicApi; +import org.microg.safeparcel.AutoSafeParcelable; + +/** + * Represents a credential that the Firebase Authentication server can use to authenticate a user. + */ +@PublicApi +public abstract class AuthCredential extends AutoSafeParcelable { + /** + * Returns the unique string identifier for the provider type with which the credential is associated. + */ + public abstract String getProvider(); + + /** + * Returns the unique string identifier for the sign in method with which the credential is associated. Should match that returned by {@link FirebaseAuth#fetchSignInMethodsForEmail(String)} after this user has signed in with this type of credential. + */ + public abstract String getSignInMethod(); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/DefaultOAuthCredential.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/DefaultOAuthCredential.java new file mode 100644 index 00000000..f224434b --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/DefaultOAuthCredential.java @@ -0,0 +1,66 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + * Notice: Portions of this file are reproduced from work created and shared by Google and used + * according to terms described in the Creative Commons 4.0 Attribution License. + * See https://developers.google.com/readme/policies for details. + */ + +package com.google.firebase.auth; + +import com.google.firebase.auth.api.internal.VerifyAssertionRequest; + +import org.microg.gms.common.PublicApi; + +@PublicApi +public class DefaultOAuthCredential extends OAuthCredential { + @Field(1) + @PublicApi(exclude = true) + public String provider; + @Field(2) + @PublicApi(exclude = true) + public String idToken; + @Field(3) + @PublicApi(exclude = true) + public String accessToken; + @Field(4) + @PublicApi(exclude = true) + public VerifyAssertionRequest webSignInToken; + @Field(5) + @PublicApi(exclude = true) + public String pendingToken; + @Field(6) + @PublicApi(exclude = true) + public String secret; + @Field(7) + @PublicApi(exclude = true) + public String rawNonce; + + + @Override + public String getAccessToken() { + return accessToken; + } + + @Override + public String getIdToken() { + return idToken; + } + + @Override + public String getSecret() { + return secret; + } + + @Override + public String getProvider() { + return provider; + } + + @Override + public String getSignInMethod() { + return provider; + } + + public static final Creator CREATOR = new AutoCreator<>(DefaultOAuthCredential.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/EmailAuthCredential.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/EmailAuthCredential.java new file mode 100644 index 00000000..d6adfd2c --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/EmailAuthCredential.java @@ -0,0 +1,54 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + * Notice: Portions of this file are reproduced from work created and shared by Google and used + * according to terms described in the Creative Commons 4.0 Attribution License. + * See https://developers.google.com/readme/policies for details. + */ + +package com.google.firebase.auth; + +import org.microg.gms.common.PublicApi; + +/** + * Wraps an email and password tuple for authentication purposes. + */ +@PublicApi +public class EmailAuthCredential extends AuthCredential { + @Field(1) + @PublicApi(exclude = true) + public String email; + @Field(2) + @PublicApi(exclude = true) + public String password; + @Field(3) + @PublicApi(exclude = true) + public String signInLink; + @Field(4) + @PublicApi(exclude = true) + public String cachedState; + @Field(5) + @PublicApi(exclude = true) + public boolean isForLinking; + + /** + * Returns the unique string identifier for the provider type with which the credential is associated. + */ + @Override + public String getProvider() { + return "password"; + } + + /** + * Returns either {@link EmailAuthProvider#EMAIL_LINK_SIGN_IN_METHOD} for a credential generated with {@link EmailAuthProvider#getCredentialWithLink(String, String)} or {@link EmailAuthProvider#EMAIL_PASSWORD_SIGN_IN_METHOD} for a credential generated with {@link EmailAuthProvider#getCredential(String, String)}. + */ + @Override + public String getSignInMethod() { + if (password != null && !password.isEmpty()) { + return "password"; + } + return "emailLink"; + } + + public static final Creator CREATOR = new AutoCreator<>(EmailAuthCredential.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/OAuthCredential.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/OAuthCredential.java new file mode 100644 index 00000000..772a456e --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/OAuthCredential.java @@ -0,0 +1,32 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + * Notice: Portions of this file are reproduced from work created and shared by Google and used + * according to terms described in the Creative Commons 4.0 Attribution License. + * See https://developers.google.com/readme/policies for details. + */ + +package com.google.firebase.auth; + +import org.microg.gms.common.PublicApi; + +/** + * Holds credentials generated by a sign-in with a credential to an IDP that uses OAuth + */ +@PublicApi +public abstract class OAuthCredential extends AuthCredential { + /** + * Returns the OAuth access token associated with this credential. + */ + public abstract String getAccessToken(); + + /** + * Returns the OAuth ID token associated with this credential. + */ + public abstract String getIdToken(); + + /** + * Returns the OAuth secret associated with this credential. This will be null for OAuth 2.0 providers. + */ + public abstract String getSecret(); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/PhoneAuthCredential.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/PhoneAuthCredential.java new file mode 100644 index 00000000..1798a307 --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/PhoneAuthCredential.java @@ -0,0 +1,64 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + * Notice: Portions of this file are reproduced from work created and shared by Google and used + * according to terms described in the Creative Commons 4.0 Attribution License. + * See https://developers.google.com/readme/policies for details. + */ + +package com.google.firebase.auth; + +import org.microg.gms.common.PublicApi; + +/** + * Wraps phone number and verification information for authentication purposes. + */ +@PublicApi +public class PhoneAuthCredential extends AuthCredential { + @Field(1) + @PublicApi(exclude = true) + public String sessionInfo; + @Field(2) + @PublicApi(exclude = true) + public String smsCode; + @Field(3) + @PublicApi(exclude = true) + public boolean hasVerificationCode; + @Field(4) + @PublicApi(exclude = true) + public String phoneNumber; + @Field(5) + @PublicApi(exclude = true) + public boolean autoCreate; + @Field(6) + @PublicApi(exclude = true) + public String temporaryProof; + @Field(7) + @PublicApi(exclude = true) + public String mfaEnrollmentId; + + /** + * Returns the unique string identifier for the provider type with which the credential is associated. + */ + @Override + public String getProvider() { + return "phone"; + } + + /** + * Returns the unique string identifier for the sign in method with which the credential is associated. Should match that returned by {@link FirebaseAuth#fetchSignInMethodsForEmail(String)} after this user has signed in with this type of credential. + */ + @Override + public String getSignInMethod() { + return "phone"; + } + + /** + * Gets the auto-retrieved SMS verification code if applicable. When SMS verification is used, you will be called back first via onCodeSent(String, PhoneAuthProvider.ForceResendingToken), and later onVerificationCompleted(PhoneAuthCredential) with a {@link PhoneAuthCredential} containing a non-null SMS code if auto-retrieval succeeded. If Firebase used another approach to verify the phone number and triggers a callback via onVerificationCompleted(PhoneAuthCredential), then SMS code can be null. + */ + public String getSmsCode() { + return smsCode; + } + + public static final Creator CREATOR = new AutoCreator<>(PhoneAuthCredential.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/UserProfileChangeRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/UserProfileChangeRequest.java new file mode 100644 index 00000000..a86c21da --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/UserProfileChangeRequest.java @@ -0,0 +1,88 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + * Notice: Portions of this file are reproduced from work created and shared by Google and used + * according to terms described in the Creative Commons 4.0 Attribution License. + * See https://developers.google.com/readme/policies for details. + */ + +package com.google.firebase.auth; + +import android.net.Uri; + +import org.microg.gms.common.PublicApi; +import org.microg.safeparcel.AutoSafeParcelable; + +/** + * Request used to update user profile information. + */ +@PublicApi +public class UserProfileChangeRequest extends AutoSafeParcelable { + @Field(1) + @PublicApi(exclude = true) + public String displayName; + @Field(2) + @PublicApi(exclude = true) + public String photoUrl; + @Field(3) + @PublicApi(exclude = true) + public boolean shouldRemoveDisplayName; + @Field(4) + @PublicApi(exclude = true) + public boolean shouldRemovePhotoUri; + + private UserProfileChangeRequest() { + } + + public String getDisplayName() { + return displayName; + } + + public Uri getPhotoUri() { + return Uri.parse(photoUrl); + } + + /** + * The request builder. + */ + public static class Builder { + private String displayName; + private Uri photoUri; + private boolean shouldRemoveDisplayName; + private boolean shouldRemovePhotoUri; + + /** + * Sets the updated display name. + * @return the {@link UserProfileChangeRequest.Builder} for chaining + */ + public Builder setDisplayName(String displayName) { + this.displayName = displayName; + shouldRemoveDisplayName = displayName == null; + return this; + } + + /** + * Sets the updated photo {@link Uri}. + * @return the {@link UserProfileChangeRequest.Builder} for chaining + */ + public Builder setPhotoUri(Uri photoUri) { + this.photoUri = photoUri; + shouldRemovePhotoUri = photoUri == null; + return this; + } + + /** + * Returns a {@link UserProfileChangeRequest} instance + */ + public UserProfileChangeRequest build() { + UserProfileChangeRequest request = new UserProfileChangeRequest(); + request.displayName = displayName; + request.photoUrl = photoUri.toString(); + request.shouldRemoveDisplayName = shouldRemoveDisplayName; + request.shouldRemovePhotoUri = shouldRemovePhotoUri; + return request; + } + } + + public static final Creator CREATOR = new AutoCreator<>(UserProfileChangeRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ApplyActionCodeAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ApplyActionCodeAidlRequest.java new file mode 100644 index 00000000..d68ed77c --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ApplyActionCodeAidlRequest.java @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class ApplyActionCodeAidlRequest extends AutoSafeParcelable { + public static final Creator CREATOR = new AutoCreator<>(ApplyActionCodeAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ChangeEmailAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ChangeEmailAidlRequest.java new file mode 100644 index 00000000..70b4e103 --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ChangeEmailAidlRequest.java @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class ChangeEmailAidlRequest extends AutoSafeParcelable { + public static final Creator CREATOR = new AutoCreator<>(ChangeEmailAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ChangePasswordAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ChangePasswordAidlRequest.java new file mode 100644 index 00000000..70823dad --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ChangePasswordAidlRequest.java @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class ChangePasswordAidlRequest extends AutoSafeParcelable { + public static final Creator CREATOR = new AutoCreator<>(ChangePasswordAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/CheckActionCodeAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/CheckActionCodeAidlRequest.java new file mode 100644 index 00000000..57f3f942 --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/CheckActionCodeAidlRequest.java @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class CheckActionCodeAidlRequest extends AutoSafeParcelable { + public static final Creator CREATOR = new AutoCreator<>(CheckActionCodeAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ConfirmPasswordResetAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ConfirmPasswordResetAidlRequest.java new file mode 100644 index 00000000..f9505ed8 --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ConfirmPasswordResetAidlRequest.java @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class ConfirmPasswordResetAidlRequest extends AutoSafeParcelable { + public static final Creator CREATOR = new AutoCreator<>(ConfirmPasswordResetAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/CreateAuthUriResponse.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/CreateAuthUriResponse.java new file mode 100644 index 00000000..e32735a4 --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/CreateAuthUriResponse.java @@ -0,0 +1,27 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +import java.util.ArrayList; +import java.util.List; + +public class CreateAuthUriResponse extends AutoSafeParcelable { + @Field(2) + public String authUri; + @Field(3) + public boolean isRegistered; + @Field(4) + public String providerId; + @Field(5) + public boolean isForExistingProvider; + @Field(6) + public StringList stringList = new StringList(); + @Field(7) + public List signInMethods = new ArrayList<>(); + public static final Creator CREATOR = new AutoCreator<>(CreateAuthUriResponse.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/CreateUserWithEmailAndPasswordAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/CreateUserWithEmailAndPasswordAidlRequest.java new file mode 100644 index 00000000..a1eb8b99 --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/CreateUserWithEmailAndPasswordAidlRequest.java @@ -0,0 +1,19 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class CreateUserWithEmailAndPasswordAidlRequest extends AutoSafeParcelable { + @Field(1) + public String email; + @Field(2) + public String password; + @Field(3) + public String tenantId; + + public static final Creator CREATOR = new AutoCreator<>(CreateUserWithEmailAndPasswordAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/DeleteAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/DeleteAidlRequest.java new file mode 100644 index 00000000..3d815a6e --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/DeleteAidlRequest.java @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class DeleteAidlRequest extends AutoSafeParcelable { + public static final Creator CREATOR = new AutoCreator<>(DeleteAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/FinalizeMfaEnrollmentAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/FinalizeMfaEnrollmentAidlRequest.java new file mode 100644 index 00000000..d76ac82f --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/FinalizeMfaEnrollmentAidlRequest.java @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class FinalizeMfaEnrollmentAidlRequest extends AutoSafeParcelable { + public static final Creator CREATOR = new AutoCreator<>(FinalizeMfaEnrollmentAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/FinalizeMfaSignInAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/FinalizeMfaSignInAidlRequest.java new file mode 100644 index 00000000..f578a740 --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/FinalizeMfaSignInAidlRequest.java @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class FinalizeMfaSignInAidlRequest extends AutoSafeParcelable { + public static final Creator CREATOR = new AutoCreator<>(FinalizeMfaSignInAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/GetAccessTokenAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/GetAccessTokenAidlRequest.java new file mode 100644 index 00000000..6b7d9e99 --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/GetAccessTokenAidlRequest.java @@ -0,0 +1,15 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class GetAccessTokenAidlRequest extends AutoSafeParcelable { + @Field(1) + public String refreshToken; + + public static final Creator CREATOR = new AutoCreator<>(GetAccessTokenAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/GetAccountInfoUser.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/GetAccountInfoUser.java new file mode 100644 index 00000000..6113649c --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/GetAccountInfoUser.java @@ -0,0 +1,43 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import com.google.firebase.auth.DefaultOAuthCredential; + +import org.microg.safeparcel.AutoSafeParcelable; + +import java.util.List; + +public class GetAccountInfoUser extends AutoSafeParcelable { + @Field(2) + public String localId; + @Field(3) + public String email; + @Field(4) + public boolean isEmailVerified; + @Field(5) + public String displayName; + @Field(6) + public String photoUrl; + @Field(7) + public ProviderUserInfoList providerInfoList = new ProviderUserInfoList(); + @Field(8) + public String password; + @Field(9) + public String phoneNumber; + @Field(10) + public long creationTimestamp; + @Field(11) + public long lastSignInTimestamp; + @Field(12) + public boolean isNewUser; + @Field(13) + public DefaultOAuthCredential defaultOAuthCredential; + @Field(14) + public List mfaInfoList; + + public static final Creator CREATOR = new AutoCreator<>(GetAccountInfoUser.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/GetProvidersForEmailAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/GetProvidersForEmailAidlRequest.java new file mode 100644 index 00000000..393bf119 --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/GetProvidersForEmailAidlRequest.java @@ -0,0 +1,16 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class GetProvidersForEmailAidlRequest extends AutoSafeParcelable { + @Field(1) + public String email; + @Field(2) + public String tenantId; + public static final Creator CREATOR = new AutoCreator<>(GetProvidersForEmailAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/GetTokenResponse.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/GetTokenResponse.java new file mode 100644 index 00000000..66e786f7 --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/GetTokenResponse.java @@ -0,0 +1,44 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.json.JSONException; +import org.json.JSONObject; +import org.microg.safeparcel.AutoSafeParcelable; + +public class GetTokenResponse extends AutoSafeParcelable { + @Field(2) + public String refreshToken; + @Field(3) + public String accessToken; + @Field(4) + public Long expiresIn; + @Field(5) + public String tokenType; + @Field(6) + public Long issuedAt; + + public GetTokenResponse() { + issuedAt = System.currentTimeMillis(); + } + + public static GetTokenResponse parseJson(String json) { + try { + JSONObject object = new JSONObject(json); + GetTokenResponse response = new GetTokenResponse(); + response.refreshToken = object.optString("refresh_token", null); + response.accessToken = object.optString("access_token", null); + response.tokenType = object.optString("token_type", null); + response.expiresIn = object.optLong("expires_in"); + response.issuedAt = object.optLong("issued_at"); + return response; + } catch (JSONException e) { + throw new RuntimeException(e); + } + } + + public static final Creator CREATOR = new AutoCreator<>(GetTokenResponse.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/LinkEmailAuthCredentialAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/LinkEmailAuthCredentialAidlRequest.java new file mode 100644 index 00000000..f80f2cee --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/LinkEmailAuthCredentialAidlRequest.java @@ -0,0 +1,18 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class LinkEmailAuthCredentialAidlRequest extends AutoSafeParcelable { + @Field(1) + public String email; + @Field(2) + public String password; + @Field(3) + public String cachedState; + public static final Creator CREATOR = new AutoCreator<>(LinkEmailAuthCredentialAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/LinkFederatedCredentialAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/LinkFederatedCredentialAidlRequest.java new file mode 100644 index 00000000..6fd81225 --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/LinkFederatedCredentialAidlRequest.java @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class LinkFederatedCredentialAidlRequest extends AutoSafeParcelable { + public static final Creator CREATOR = new AutoCreator<>(LinkFederatedCredentialAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/LinkPhoneAuthCredentialAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/LinkPhoneAuthCredentialAidlRequest.java new file mode 100644 index 00000000..afc653b4 --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/LinkPhoneAuthCredentialAidlRequest.java @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class LinkPhoneAuthCredentialAidlRequest extends AutoSafeParcelable { + public static final Creator CREATOR = new AutoCreator<>(LinkPhoneAuthCredentialAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/MfaInfo.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/MfaInfo.java new file mode 100644 index 00000000..1e2ddaf0 --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/MfaInfo.java @@ -0,0 +1,14 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class MfaInfo extends AutoSafeParcelable { + + + public static final Creator CREATOR = new AutoCreator<>(MfaInfo.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ProviderUserInfo.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ProviderUserInfo.java new file mode 100644 index 00000000..1f7a19b0 --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ProviderUserInfo.java @@ -0,0 +1,27 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class ProviderUserInfo extends AutoSafeParcelable { + @Field(2) + public String federatedId; + @Field(3) + public String displayName; + @Field(4) + public String photoUrl; + @Field(5) + public String providerId; + @Field(6) + public String rawUserInfo; + @Field(7) + public String phoneNumber; + @Field(8) + public String email; + + public static final Creator CREATOR = new AutoCreator<>(ProviderUserInfo.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ProviderUserInfoList.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ProviderUserInfoList.java new file mode 100644 index 00000000..ff99d31e --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ProviderUserInfoList.java @@ -0,0 +1,19 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +import java.util.ArrayList; +import java.util.List; + +public class ProviderUserInfoList extends AutoSafeParcelable { + @Field(2) + public List providerUserInfos = new ArrayList<>(); + + + public static final Creator CREATOR = new AutoCreator<>(ProviderUserInfoList.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ReloadAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ReloadAidlRequest.java new file mode 100644 index 00000000..de609f76 --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ReloadAidlRequest.java @@ -0,0 +1,14 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class ReloadAidlRequest extends AutoSafeParcelable { + @Field(1) + public String cachedState; + public static final Creator CREATOR = new AutoCreator<>(ReloadAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ResetPasswordResponse.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ResetPasswordResponse.java new file mode 100644 index 00000000..06af0636 --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/ResetPasswordResponse.java @@ -0,0 +1,20 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class ResetPasswordResponse extends AutoSafeParcelable { + @Field(2) + public String email; + @Field(3) + public String newEmail; + @Field(4) + public String requestType; + @Field(5) + public MfaInfo mfaInfo; + public static final Creator CREATOR = new AutoCreator<>(ResetPasswordResponse.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SendEmailVerificationWithSettingsAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SendEmailVerificationWithSettingsAidlRequest.java new file mode 100644 index 00000000..9bda971e --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SendEmailVerificationWithSettingsAidlRequest.java @@ -0,0 +1,18 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import com.google.firebase.auth.ActionCodeSettings; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class SendEmailVerificationWithSettingsAidlRequest extends AutoSafeParcelable { + @Field(1) + public String token; + @Field(2) + public ActionCodeSettings settings; + public static final Creator CREATOR = new AutoCreator<>(SendEmailVerificationWithSettingsAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SendGetOobConfirmationCodeEmailAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SendGetOobConfirmationCodeEmailAidlRequest.java new file mode 100644 index 00000000..04dd49cc --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SendGetOobConfirmationCodeEmailAidlRequest.java @@ -0,0 +1,20 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import com.google.firebase.auth.ActionCodeSettings; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class SendGetOobConfirmationCodeEmailAidlRequest extends AutoSafeParcelable { + @Field(1) + public String email; + @Field(2) + public ActionCodeSettings settings; + @Field(3) + public String tenantId; + public static final Creator CREATOR = new AutoCreator<>(SendGetOobConfirmationCodeEmailAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SendVerificationCodeAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SendVerificationCodeAidlRequest.java new file mode 100644 index 00000000..9b3eccd3 --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SendVerificationCodeAidlRequest.java @@ -0,0 +1,14 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class SendVerificationCodeAidlRequest extends AutoSafeParcelable { + @Field(1) + public SendVerificationCodeRequest request; + public static final Creator CREATOR = new AutoCreator<>(SendVerificationCodeAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SendVerificationCodeRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SendVerificationCodeRequest.java new file mode 100644 index 00000000..971d6fa7 --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SendVerificationCodeRequest.java @@ -0,0 +1,25 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class SendVerificationCodeRequest extends AutoSafeParcelable { + @Field(1) + public String phoneNumber; + @Field(2) + public Long timeoutInSeconds; + @Field(3) + public boolean forceNewSmsVerificationSession; + @Field(4) + public String languageHeader; + @Field(5) + public String tenantId; + @Field(6) + public String recaptchaToken; + + public static final Creator CREATOR = new AutoCreator<>(SendVerificationCodeRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SetFirebaseUiVersionAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SetFirebaseUiVersionAidlRequest.java new file mode 100644 index 00000000..964382e8 --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SetFirebaseUiVersionAidlRequest.java @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class SetFirebaseUiVersionAidlRequest extends AutoSafeParcelable { + public static final Creator CREATOR = new AutoCreator<>(SetFirebaseUiVersionAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SignInAnonymouslyAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SignInAnonymouslyAidlRequest.java new file mode 100644 index 00000000..2549412d --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SignInAnonymouslyAidlRequest.java @@ -0,0 +1,14 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class SignInAnonymouslyAidlRequest extends AutoSafeParcelable { + @Field(1) + public String tenantId; + public static final Creator CREATOR = new AutoCreator<>(SignInAnonymouslyAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SignInWithCredentialAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SignInWithCredentialAidlRequest.java new file mode 100644 index 00000000..94190acb --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SignInWithCredentialAidlRequest.java @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class SignInWithCredentialAidlRequest extends AutoSafeParcelable { + public static final Creator CREATOR = new AutoCreator<>(SignInWithCredentialAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SignInWithCustomTokenAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SignInWithCustomTokenAidlRequest.java new file mode 100644 index 00000000..0f7f1077 --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SignInWithCustomTokenAidlRequest.java @@ -0,0 +1,17 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class SignInWithCustomTokenAidlRequest extends AutoSafeParcelable { + @Field(1) + public String token; + @Field(2) + public String tenantId; + + public static final Creator CREATOR = new AutoCreator<>(SignInWithCustomTokenAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SignInWithEmailAndPasswordAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SignInWithEmailAndPasswordAidlRequest.java new file mode 100644 index 00000000..c8aa04d9 --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SignInWithEmailAndPasswordAidlRequest.java @@ -0,0 +1,18 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class SignInWithEmailAndPasswordAidlRequest extends AutoSafeParcelable { + @Field(1) + public String email; + @Field(2) + public String password; + @Field(3) + public String tenantId; + public static final Creator CREATOR = new AutoCreator<>(SignInWithEmailAndPasswordAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SignInWithEmailLinkAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SignInWithEmailLinkAidlRequest.java new file mode 100644 index 00000000..71028fa1 --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SignInWithEmailLinkAidlRequest.java @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class SignInWithEmailLinkAidlRequest extends AutoSafeParcelable { + public static final Creator CREATOR = new AutoCreator<>(SignInWithEmailLinkAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SignInWithPhoneNumberAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SignInWithPhoneNumberAidlRequest.java new file mode 100644 index 00000000..d076cf30 --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/SignInWithPhoneNumberAidlRequest.java @@ -0,0 +1,19 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import com.google.firebase.auth.PhoneAuthCredential; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class SignInWithPhoneNumberAidlRequest extends AutoSafeParcelable { + @Field(1) + public PhoneAuthCredential credential; + @Field(2) + public String tenantId; + + public static final Creator CREATOR = new AutoCreator<>(SignInWithPhoneNumberAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/StartMfaPhoneNumberEnrollmentAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/StartMfaPhoneNumberEnrollmentAidlRequest.java new file mode 100644 index 00000000..b4a93b6b --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/StartMfaPhoneNumberEnrollmentAidlRequest.java @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class StartMfaPhoneNumberEnrollmentAidlRequest extends AutoSafeParcelable { + public static final Creator CREATOR = new AutoCreator<>(StartMfaPhoneNumberEnrollmentAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/StartMfaPhoneNumberSignInAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/StartMfaPhoneNumberSignInAidlRequest.java new file mode 100644 index 00000000..151d4e6e --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/StartMfaPhoneNumberSignInAidlRequest.java @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class StartMfaPhoneNumberSignInAidlRequest extends AutoSafeParcelable { + public static final Creator CREATOR = new AutoCreator<>(StartMfaPhoneNumberSignInAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/StringList.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/StringList.java new file mode 100644 index 00000000..8c72245c --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/StringList.java @@ -0,0 +1,19 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +import java.util.ArrayList; +import java.util.List; + +public class StringList extends AutoSafeParcelable { + @Field(1) + public int versionCode = 1; + @Field(2) + public List values = new ArrayList<>(); + public static final Creator CREATOR = new AutoCreator<>(StringList.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/UnenrollMfaAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/UnenrollMfaAidlRequest.java new file mode 100644 index 00000000..49c4b0f6 --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/UnenrollMfaAidlRequest.java @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class UnenrollMfaAidlRequest extends AutoSafeParcelable { + public static final Creator CREATOR = new AutoCreator<>(UnenrollMfaAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/UnlinkEmailCredentialAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/UnlinkEmailCredentialAidlRequest.java new file mode 100644 index 00000000..55770dd9 --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/UnlinkEmailCredentialAidlRequest.java @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class UnlinkEmailCredentialAidlRequest extends AutoSafeParcelable { + public static final Creator CREATOR = new AutoCreator<>(UnlinkEmailCredentialAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/UnlinkFederatedCredentialAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/UnlinkFederatedCredentialAidlRequest.java new file mode 100644 index 00000000..1533997c --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/UnlinkFederatedCredentialAidlRequest.java @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class UnlinkFederatedCredentialAidlRequest extends AutoSafeParcelable { + public static final Creator CREATOR = new AutoCreator<>(UnlinkFederatedCredentialAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/UpdateProfileAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/UpdateProfileAidlRequest.java new file mode 100644 index 00000000..25d40202 --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/UpdateProfileAidlRequest.java @@ -0,0 +1,18 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import com.google.firebase.auth.UserProfileChangeRequest; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class UpdateProfileAidlRequest extends AutoSafeParcelable { + @Field(1) + public UserProfileChangeRequest request; + @Field(2) + public String cachedState; + public static final Creator CREATOR = new AutoCreator<>(UpdateProfileAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/VerifyAssertionRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/VerifyAssertionRequest.java new file mode 100644 index 00000000..47e3c220 --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/VerifyAssertionRequest.java @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class VerifyAssertionRequest extends AutoSafeParcelable { + public static final Creator CREATOR = new AutoCreator<>(VerifyAssertionRequest.class); +} diff --git a/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/VerifyBeforeUpdateEmailAidlRequest.java b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/VerifyBeforeUpdateEmailAidlRequest.java new file mode 100644 index 00000000..d6d5c121 --- /dev/null +++ b/firebase-auth-api/src/main/java/com/google/firebase/auth/api/internal/VerifyBeforeUpdateEmailAidlRequest.java @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.firebase.auth.api.internal; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class VerifyBeforeUpdateEmailAidlRequest extends AutoSafeParcelable { + public static final Creator CREATOR = new AutoCreator<>(VerifyBeforeUpdateEmailAidlRequest.class); +} diff --git a/firebase-auth-api/src/main/java/org/microg/gms/firebase/auth/Constants.java b/firebase-auth-api/src/main/java/org/microg/gms/firebase/auth/Constants.java new file mode 100644 index 00000000..0f83c9fe --- /dev/null +++ b/firebase-auth-api/src/main/java/org/microg/gms/firebase/auth/Constants.java @@ -0,0 +1,11 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.microg.gms.firebase.auth; + +public class Constants { + public static final String EXTRA_API_KEY = "com.google.firebase.auth.API_KEY"; + public static final String EXTRA_LIBRARY_VERSION = "com.google.firebase.auth.LIBRARY_VERSION"; +} diff --git a/firebase-auth-core/build.gradle b/firebase-auth-core/build.gradle new file mode 100644 index 00000000..4a2e3e46 --- /dev/null +++ b/firebase-auth-core/build.gradle @@ -0,0 +1,46 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +dependencies { + api project(':firebase-auth-api') + + implementation "androidx.lifecycle:lifecycle-service:$lifecycleVersion" + implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion" + + implementation "androidx.appcompat:appcompat:$appcompatVersion" + + implementation project(':play-services-base-core') + implementation project(':play-services-base-core-ui') + + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutineVersion" + + implementation "com.android.volley:volley:$volleyVersion" +} + +android { + compileSdkVersion androidCompileSdk + buildToolsVersion "$androidBuildVersionTools" + + defaultConfig { + versionName version + minSdkVersion androidMinSdk + targetSdkVersion androidTargetSdk + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + compileOptions { + sourceCompatibility = 1.8 + targetCompatibility = 1.8 + } +} diff --git a/firebase-auth-core/src/main/AndroidManifest.xml b/firebase-auth-core/src/main/AndroidManifest.xml new file mode 100644 index 00000000..d3507793 --- /dev/null +++ b/firebase-auth-core/src/main/AndroidManifest.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + diff --git a/firebase-auth-core/src/main/assets/recaptcha.html b/firebase-auth-core/src/main/assets/recaptcha.html new file mode 100644 index 00000000..3da22b32 --- /dev/null +++ b/firebase-auth-core/src/main/assets/recaptcha.html @@ -0,0 +1,54 @@ + + + + +

+
+ + + + + + + + + + + + + + +
+ + + + + + + + diff --git a/firebase-auth-core/src/main/kotlin/org/microg/gms/firebase/auth/FirebaseAuthService.kt b/firebase-auth-core/src/main/kotlin/org/microg/gms/firebase/auth/FirebaseAuthService.kt new file mode 100644 index 00000000..18f9d9e3 --- /dev/null +++ b/firebase-auth-core/src/main/kotlin/org/microg/gms/firebase/auth/FirebaseAuthService.kt @@ -0,0 +1,649 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.microg.gms.firebase.auth + +import android.content.BroadcastReceiver +import android.content.Context +import android.content.Intent +import android.content.IntentFilter +import android.os.Build +import android.os.Handler +import android.os.Parcel +import android.provider.Telephony +import android.telephony.SmsMessage +import android.util.Log +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.LifecycleOwner +import androidx.lifecycle.lifecycleScope +import com.google.android.gms.common.api.CommonStatusCodes +import com.google.android.gms.common.api.Status +import com.google.android.gms.common.internal.GetServiceRequest +import com.google.android.gms.common.internal.IGmsCallbacks +import com.google.firebase.auth.ActionCodeSettings +import com.google.firebase.auth.EmailAuthCredential +import com.google.firebase.auth.PhoneAuthCredential +import com.google.firebase.auth.UserProfileChangeRequest +import com.google.firebase.auth.api.internal.* +import org.json.JSONArray +import org.json.JSONObject +import org.microg.gms.BaseService +import org.microg.gms.common.GmsService +import org.microg.gms.common.PackageUtils + +private const val TAG = "GmsFirebaseAuth" + +fun JSONObject.getStringOrNull(key: String) = if (has(key)) getString(key) else null +fun JSONObject.getJSONArrayOrNull(key: String) = if (has(key)) getJSONArray(key) else null +fun JSONArray?.orEmpty() = this ?: JSONArray() +fun JSONObject.getJSONArrayLength(key: String) = getJSONArrayOrNull(key).orEmpty().length() + +private val ActionCodeSettings.requestTypeAsString: String + get() = when (requestType) { + 1 -> "PASSWORD_RESET" + 2 -> "OLD_EMAIL_AGREE" + 3 -> "NEW_EMAIL_ACCEPT" + 4 -> "VERIFY_EMAIL" + 5 -> "RECOVER_EMAIL" + 6 -> "EMAIL_SIGNIN" + 7 -> "VERIFY_AND_CHANGE_EMAIL" + 8 -> "REVERT_SECOND_FACTOR_ADDITION" + else -> "OOB_REQ_TYPE_UNSPECIFIED" + } + +private val UserProfileChangeRequest.deleteAttributeList: List + get() { + val list = arrayListOf() + if (shouldRemoveDisplayName) list.add("DISPLAY_NAME") + if (shouldRemovePhotoUri) list.add("PHOTO_URL") + return list + } + +private fun Intent.getSmsMessages(): Array { + return if (Build.VERSION.SDK_INT >= 19) { + Telephony.Sms.Intents.getMessagesFromIntent(this) + } else { + (getSerializableExtra("pdus") as? Array)?.map { SmsMessage.createFromPdu(it) }.orEmpty().toTypedArray() + } +} + +class FirebaseAuthService : BaseService(TAG, GmsService.FIREBASE_AUTH) { + override fun handleServiceRequest(callback: IGmsCallbacks, request: GetServiceRequest, service: GmsService?) { + PackageUtils.getAndCheckCallingPackage(this, request.packageName) + val apiKey = request.extras?.getString(Constants.EXTRA_API_KEY) + val libraryVersion = request.extras?.getString(Constants.EXTRA_LIBRARY_VERSION) + if (apiKey == null || libraryVersion == null) { + callback.onPostInitComplete(CommonStatusCodes.DEVELOPER_ERROR, null, null) + } else { + callback.onPostInitComplete(0, FirebaseAuthServiceImpl(this, lifecycle, request.packageName, libraryVersion, apiKey).asBinder(), null) + } + } +} + +class FirebaseAuthServiceImpl(private val context: Context, private val lifecycle: Lifecycle, private val packageName: String, private val libraryVersion: String, private val apiKey: String) : IFirebaseAuthService.Stub(), LifecycleOwner { + private val client = IdentityToolkitClient(context, apiKey) + private var authorizedDomain: String? = null + + private suspend fun getAuthorizedDomain(): String { + authorizedDomain?.let { return it } + val authorizedDomain = try { + client.getProjectConfig().getJSONArray("authorizedDomains").getString(0) + } catch (e: Exception) { + Log.w(TAG, e) + "localhost" + } + this.authorizedDomain = authorizedDomain + return authorizedDomain + } + + private suspend fun refreshTokenResponse(cachedState: String): GetTokenResponse { + var tokenResponse = GetTokenResponse.parseJson(cachedState) + if (System.currentTimeMillis() + 300000L < tokenResponse.issuedAt + tokenResponse.expiresIn * 1000) { + return tokenResponse + } + return client.getTokenByRefreshToken(tokenResponse.refreshToken).toGetTokenResponse() + } + + private fun JSONObject.toGetTokenResponse() = GetTokenResponse().apply { + refreshToken = getStringOrNull("refresh_token") + accessToken = getStringOrNull("access_token") + expiresIn = getStringOrNull("expires_in")?.toLong() + tokenType = getStringOrNull("token_type") + } + + private fun JSONObject.toGetAccountInfoUser(): GetAccountInfoUser = GetAccountInfoUser().apply { + localId = getStringOrNull("localId") + email = getStringOrNull("email") + isEmailVerified = optBoolean("emailVerified") + displayName = getStringOrNull("displayName") + photoUrl = getStringOrNull("photoUrl") + for (i in 0 until getJSONArrayLength("providerUserInfo")) { + getJSONArray("providerUserInfo").getJSONObject(i).run { + providerInfoList.providerUserInfos.add(ProviderUserInfo().apply { + federatedId = getStringOrNull("federatedId") + displayName = getStringOrNull("displayName") + photoUrl = getStringOrNull("photoUrl") + providerId = getStringOrNull("providerId") + phoneNumber = getStringOrNull("phoneNumber") + email = getStringOrNull("email") + rawUserInfo = this@run.toString() + }) + } + } + password = getStringOrNull("rawPassword") + phoneNumber = getStringOrNull("phoneNumber") + creationTimestamp = getStringOrNull("createdAt")?.toLong() ?: 0L + lastSignInTimestamp = getStringOrNull("lastLoginAt")?.toLong() ?: 0L + } + + private fun JSONObject.toCreateAuthUriResponse(): CreateAuthUriResponse = CreateAuthUriResponse().apply { + authUri = getStringOrNull("authUri") + isRegistered = optBoolean("registered") + providerId = getStringOrNull("providerId") + isForExistingProvider = optBoolean("forExistingProvider") + for (i in 0 until getJSONArrayLength("allProviders")) { + stringList.values.add(getJSONArray("allProviders").getString(i)) + } + for (i in 0 until getJSONArrayLength("signinMethods")) { + signInMethods.add(getJSONArray("signinMethods").getString(i)) + } + } + + override fun getLifecycle(): Lifecycle = lifecycle + + override fun applyActionCode(request: ApplyActionCodeAidlRequest, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: applyActionCode") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun applyActionCodeCompat(code: String?, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: applyActionCodeCompat") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun changeEmail(request: ChangeEmailAidlRequest, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: changeEmail") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun changeEmailCompat(cachedState: String?, email: String?, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: changeEmailCompat") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun changePassword(request: ChangePasswordAidlRequest, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: changePassword") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun changePasswordCompat(cachedState: String?, password: String?, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: changePasswordCompat") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun checkActionCode(request: CheckActionCodeAidlRequest, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: checkActionCode") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun checkActionCodeCompat(code: String?, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: checkActionCodeCompat") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun confirmPasswordReset(request: ConfirmPasswordResetAidlRequest, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: confirmPasswordReset") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun confirmPasswordResetCompat(code: String?, newPassword: String?, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: confirmPasswordResetCompat") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun createUserWithEmailAndPassword(request: CreateUserWithEmailAndPasswordAidlRequest, callbacks: IFirebaseAuthCallbacks) { + lifecycleScope.launchWhenStarted { + Log.d(TAG, "createUserWithEmailAndPassword") + try { + val tokenResult = client.signupNewUser(email = request.email, password = request.password, tenantId = request.tenantId) + val idToken = tokenResult.getString("idToken") + val refreshToken = tokenResult.getString("refreshToken") + val getTokenResponse = client.getTokenByRefreshToken(refreshToken).toGetTokenResponse() + val accountInfoResult = client.getAccountInfo(idToken = idToken).getJSONArray("users").getJSONObject(0).toGetAccountInfoUser().apply { this.isNewUser = true } + Log.d(TAG, "callback: onGetTokenResponseAndUser") + callbacks.onGetTokenResponseAndUser(getTokenResponse, accountInfoResult) + } catch (e: Exception) { + Log.w(TAG, "callback: onFailure", e) + callbacks.onFailure(Status(CommonStatusCodes.INTERNAL_ERROR, e.message)) + } + } + } + + override fun createUserWithEmailAndPasswordCompat(email: String?, password: String?, callbacks: IFirebaseAuthCallbacks) { + createUserWithEmailAndPassword(CreateUserWithEmailAndPasswordAidlRequest().apply { this.email = email; this.password = password }, callbacks) + } + + override fun delete(request: DeleteAidlRequest, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: delete") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun deleteCompat(cachedState: String?, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: deleteCompat") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun finalizeMfaEnrollment(request: FinalizeMfaEnrollmentAidlRequest, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: finalizeMfaEnrollment") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun finalizeMfaSignIn(request: FinalizeMfaSignInAidlRequest, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: finalizeMfaSignIn") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun getAccessToken(request: GetAccessTokenAidlRequest, callbacks: IFirebaseAuthCallbacks) { + lifecycleScope.launchWhenStarted { + Log.d(TAG, "getAccessToken") + try { + callbacks.onGetTokenResponse(client.getTokenByRefreshToken(request.refreshToken).toGetTokenResponse()) + } catch (e: Exception) { + Log.w(TAG, "callback: onFailure", e) + callbacks.onFailure(Status(CommonStatusCodes.INTERNAL_ERROR, e.message)) + } + } + } + + override fun getAccessTokenCompat(refreshToken: String?, callbacks: IFirebaseAuthCallbacks) { + getAccessToken(GetAccessTokenAidlRequest().apply { this.refreshToken = refreshToken }, callbacks) + } + + override fun getProvidersForEmail(request: GetProvidersForEmailAidlRequest, callbacks: IFirebaseAuthCallbacks) { + lifecycleScope.launchWhenStarted { + Log.d(TAG, "getProvidersForEmail") + try { + callbacks.onCreateAuthUriResponse(client.createAuthUri(identifier = request.email, tenantId = request.tenantId).toCreateAuthUriResponse()) + } catch (e: Exception) { + Log.w(TAG, "callback: onFailure", e) + callbacks.onFailure(Status(CommonStatusCodes.INTERNAL_ERROR, e.message)) + } + } + } + + override fun getProvidersForEmailCompat(email: String?, callbacks: IFirebaseAuthCallbacks) { + getProvidersForEmail(GetProvidersForEmailAidlRequest().apply { this.email = email }, callbacks) + } + + override fun linkEmailAuthCredential(request: LinkEmailAuthCredentialAidlRequest, callbacks: IFirebaseAuthCallbacks) { + lifecycleScope.launchWhenStarted { + Log.d(TAG, "linkEmailAuthCredential") + try { + val getTokenResponse = refreshTokenResponse(request.cachedState) + val accountInfoResult = client.getAccountInfo(idToken = getTokenResponse.accessToken).getJSONArray("users").getJSONObject(0).toGetAccountInfoUser() + val setAccountInfo = client.setAccountInfo(idToken = getTokenResponse.accessToken, localId = accountInfoResult.localId, email = request.email, password = request.password).toGetAccountInfoUser() + accountInfoResult.email = setAccountInfo.email + accountInfoResult.isEmailVerified = setAccountInfo.isEmailVerified + accountInfoResult.providerInfoList = setAccountInfo.providerInfoList + callbacks.onGetTokenResponseAndUser(getTokenResponse, accountInfoResult) + } catch (e: Exception) { + Log.w(TAG, "callback: onFailure", e) + callbacks.onFailure(Status(CommonStatusCodes.INTERNAL_ERROR, e.message)) + } + } + } + + override fun linkEmailAuthCredentialCompat(email: String?, password: String?, cachedState: String?, callbacks: IFirebaseAuthCallbacks) { + linkEmailAuthCredential(LinkEmailAuthCredentialAidlRequest().apply { this.email = email; this.password = password; this.cachedState = cachedState }, callbacks) + } + + override fun linkFederatedCredential(request: LinkFederatedCredentialAidlRequest, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: linkFederatedCredential") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun linkFederatedCredentialCompat(cachedState: String?, verifyAssertionRequest: VerifyAssertionRequest, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: linkFederatedCredentialCompat") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun linkPhoneAuthCredential(request: LinkPhoneAuthCredentialAidlRequest, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: linkPhoneAuthCredential") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun linkPhoneAuthCredentialCompat(cachedState: String?, credential: PhoneAuthCredential?, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: linkPhoneAuthCredentialCompat") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun reload(request: ReloadAidlRequest, callbacks: IFirebaseAuthCallbacks) { + lifecycleScope.launchWhenStarted { + try { + Log.d(TAG, "reload") + val getTokenResponse = refreshTokenResponse(request.cachedState) + val accountInfoResult = client.getAccountInfo(idToken = getTokenResponse.accessToken).getJSONArray("users").getJSONObject(0).toGetAccountInfoUser() + Log.d(TAG, "callback: onGetTokenResponseAndUser") + callbacks.onGetTokenResponseAndUser(getTokenResponse, accountInfoResult) + } catch (e: Exception) { + Log.w(TAG, "callback: onFailure", e) + callbacks.onFailure(Status(CommonStatusCodes.INTERNAL_ERROR, e.message)) + } + } + } + + override fun reloadCompat(cachedState: String?, callbacks: IFirebaseAuthCallbacks) { + reload(ReloadAidlRequest().apply { this.cachedState = cachedState }, callbacks) + } + + override fun sendEmailVerification(request: SendEmailVerificationWithSettingsAidlRequest, callbacks: IFirebaseAuthCallbacks) { + lifecycleScope.launchWhenStarted { + try { + Log.d(TAG, "sendEmailVerification") + client.getOobConfirmationCode( + requestType = "VERIFY_EMAIL", + idToken = request.token, + iOSBundleId = request.settings?.iOSBundle, + iOSAppStoreId = request.settings?.iOSAppStoreId, + continueUrl = request.settings?.url, + androidInstallApp = request.settings?.androidInstallApp, + androidMinimumVersion = request.settings?.androidMinimumVersion, + androidPackageName = request.settings?.androidPackageName, + canHandleCodeInApp = request.settings?.handleCodeInApp + ) + callbacks.onEmailVerificationResponse() + } catch (e: Exception) { + Log.w(TAG, "callback: onFailure", e) + callbacks.onFailure(Status(CommonStatusCodes.INTERNAL_ERROR, e.message)) + } + } + } + + override fun sendEmailVerificationCompat(token: String?, actionCodeSettings: ActionCodeSettings?, callbacks: IFirebaseAuthCallbacks) { + sendEmailVerification(SendEmailVerificationWithSettingsAidlRequest().apply { this.token = token; this.settings = actionCodeSettings }, callbacks) + } + + override fun sendVerificationCode(request: SendVerificationCodeAidlRequest, callbacks: IFirebaseAuthCallbacks) { + lifecycleScope.launchWhenStarted { + try { + Log.d(TAG, "sendVerificationCode") + val reCaptchaToken = when { + request.request.recaptchaToken != null -> request.request.recaptchaToken + ReCaptchaOverlay.isSupported(context) -> ReCaptchaOverlay.awaitToken(context, apiKey, getAuthorizedDomain()) + ReCaptchaActivity.isSupported(context) -> ReCaptchaActivity.awaitToken(context, apiKey, getAuthorizedDomain()) + else -> throw RuntimeException("No recaptcha token available") + } + var sessionInfo: String? = null + var registered = true + val receiver = object : BroadcastReceiver() { + override fun onReceive(context: Context, intent: Intent) { + var smsCode: String? = null + for (message in intent.getSmsMessages()) { + smsCode = Regex("\\b([0-9]{6})\\b").find(message.messageBody)?.groups?.get(1)?.value + ?: continue + Log.d(TAG, "Received SMS verification code: $smsCode") + break + } + if (smsCode == null) return + registered = false + context.unregisterReceiver(this) + try { + callbacks.onVerificationCompletedResponse(PhoneAuthCredential().apply { + this.phoneNumber = request.request.phoneNumber + this.sessionInfo = sessionInfo + this.smsCode = smsCode + }) + Log.d(TAG, "callback: onVerificationCompletedResponse") + } catch (e: Exception) { + Log.w(TAG, e) + } + } + } + context.registerReceiver(receiver, IntentFilter("android.provider.Telephony.SMS_RECEIVED")) + var timeout = request.request.timeoutInSeconds * 1000L + if (timeout <= 0L) timeout = 120000L + Handler().postDelayed({ + if (registered) { + Log.d(TAG, "Waited ${timeout}ms for verification code SMS, timeout.") + context.unregisterReceiver(receiver) + callbacks.onVerificationAutoTimeOut(sessionInfo) + Log.d(TAG, "callback: onVerificationAutoTimeOut") + } + }, timeout) + sessionInfo = client.sendVerificationCode(phoneNumber = request.request.phoneNumber, reCaptchaToken = reCaptchaToken).getString("sessionInfo") + callbacks.onSendVerificationCodeResponse(sessionInfo) + Log.d(TAG, "callback: onSendVerificationCodeResponse") + } catch (e: Exception) { + Log.w(TAG, "callback: onFailure", e) + callbacks.onFailure(Status(CommonStatusCodes.INTERNAL_ERROR, e.message)) + } + } + } + + override fun sendVerificationCodeCompat(request: SendVerificationCodeRequest, callbacks: IFirebaseAuthCallbacks) { + sendVerificationCode(SendVerificationCodeAidlRequest().apply { this.request = request }, callbacks) + } + + override fun sendGetOobConfirmationCodeEmail(request: SendGetOobConfirmationCodeEmailAidlRequest, callbacks: IFirebaseAuthCallbacks) { + lifecycleScope.launchWhenStarted { + try { + Log.d(TAG, "sendGetOobConfirmationCodeEmail") + client.getOobConfirmationCode( + requestType = request.settings?.requestTypeAsString ?: "OOB_REQ_TYPE_UNSPECIFIED", + email = request.email, + iOSBundleId = request.settings?.iOSBundle, + iOSAppStoreId = request.settings?.iOSAppStoreId, + continueUrl = request.settings?.url, + androidInstallApp = request.settings?.androidInstallApp, + androidMinimumVersion = request.settings?.androidMinimumVersion, + androidPackageName = request.settings?.androidPackageName, + canHandleCodeInApp = request.settings?.handleCodeInApp + ) + Log.d(TAG, "callback: onResetPasswordResponse") + callbacks.onResetPasswordResponse(null) + } catch (e: Exception) { + Log.w(TAG, "callback: onFailure", e) + callbacks.onFailure(Status(CommonStatusCodes.INTERNAL_ERROR, e.message)) + } + } + } + + override fun sendGetOobConfirmationCodeEmailCompat(email: String?, actionCodeSettings: ActionCodeSettings?, callbacks: IFirebaseAuthCallbacks) { + sendGetOobConfirmationCodeEmail(SendGetOobConfirmationCodeEmailAidlRequest().apply { this.email = email; this.settings = actionCodeSettings }, callbacks) + } + + override fun setFirebaseUiVersion(request: SetFirebaseUiVersionAidlRequest, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: setFirebaseUiVersion") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun setFirebaseUIVersionCompat(firebaseUiVersion: String?, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: setFirebaseUIVersionCompat") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun signInAnonymously(request: SignInAnonymouslyAidlRequest, callbacks: IFirebaseAuthCallbacks) { + lifecycleScope.launchWhenStarted { + Log.d(TAG, "signInAnonymously") + try { + val tokenResult = client.signupNewUser(tenantId = request.tenantId) + val idToken = tokenResult.getString("idToken") + val refreshToken = tokenResult.getString("refreshToken") + val getTokenResponse = client.getTokenByRefreshToken(refreshToken).toGetTokenResponse() + val accountInfoResult = client.getAccountInfo(idToken = idToken).getJSONArray("users").getJSONObject(0).toGetAccountInfoUser().apply { this.isNewUser = true } + Log.d(TAG, "callback: onGetTokenResponseAndUser") + callbacks.onGetTokenResponseAndUser(getTokenResponse, accountInfoResult) + } catch (e: Exception) { + Log.w(TAG, "callback: onFailure", e) + callbacks.onFailure(Status(CommonStatusCodes.INTERNAL_ERROR, e.message)) + } + } + } + + override fun signInAnonymouslyCompat(callbacks: IFirebaseAuthCallbacks) { + signInAnonymously(SignInAnonymouslyAidlRequest(), callbacks) + } + + override fun signInWithCredential(request: SignInWithCredentialAidlRequest, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: signInWithCredential") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun signInWithCredentialCompat(verifyAssertionRequest: VerifyAssertionRequest, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: signInWithCredentialCompat") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun signInWithCustomToken(request: SignInWithCustomTokenAidlRequest, callbacks: IFirebaseAuthCallbacks) { + lifecycleScope.launchWhenStarted { + Log.d(TAG, "signInWithCustomToken") + try { + val tokenResult = client.verifyCustomToken(token = request.token) + val idToken = tokenResult.getString("idToken") + val refreshToken = tokenResult.getString("refreshToken") + val isNewUser = tokenResult.optBoolean("isNewUser") + val getTokenResponse = client.getTokenByRefreshToken(refreshToken).toGetTokenResponse() + val accountInfoResult = client.getAccountInfo(idToken = idToken).getJSONArray("users").getJSONObject(0).toGetAccountInfoUser().apply { this.isNewUser = isNewUser } + Log.d(TAG, "callback: onGetTokenResponseAndUser") + callbacks.onGetTokenResponseAndUser(getTokenResponse, accountInfoResult) + } catch (e: Exception) { + Log.w(TAG, "callback: onFailure", e) + callbacks.onFailure(Status(CommonStatusCodes.INTERNAL_ERROR, e.message)) + } + } + } + + override fun signInWithCustomTokenCompat(token: String, callbacks: IFirebaseAuthCallbacks) { + signInWithCustomToken(SignInWithCustomTokenAidlRequest().apply { this.token = token }, callbacks) + } + + override fun signInWithEmailAndPassword(request: SignInWithEmailAndPasswordAidlRequest, callbacks: IFirebaseAuthCallbacks) { + lifecycleScope.launchWhenStarted { + Log.d(TAG, "signInWithEmailAndPassword") + try { + val tokenResult = client.verifyPassword(email = request.email, password = request.password, tenantId = request.tenantId) + val idToken = tokenResult.getString("idToken") + val refreshToken = tokenResult.getString("refreshToken") + val getTokenResponse = client.getTokenByRefreshToken(refreshToken).toGetTokenResponse() + val accountInfoResult = client.getAccountInfo(idToken = idToken).getJSONArray("users").getJSONObject(0).toGetAccountInfoUser() + Log.d(TAG, "callback: onGetTokenResponseAndUser") + callbacks.onGetTokenResponseAndUser(getTokenResponse, accountInfoResult) + } catch (e: Exception) { + Log.w(TAG, "callback: onFailure", e) + callbacks.onFailure(Status(CommonStatusCodes.INTERNAL_ERROR, e.message)) + } + } + } + + override fun signInWithEmailAndPasswordCompat(email: String?, password: String?, callbacks: IFirebaseAuthCallbacks) { + signInWithEmailAndPassword(SignInWithEmailAndPasswordAidlRequest().apply { this.email = email; this.password = password }, callbacks) + } + + override fun signInWithEmailLink(request: SignInWithEmailLinkAidlRequest, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: signInWithEmailLink") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun signInWithEmailLinkCompat(credential: EmailAuthCredential?, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: signInWithEmailLinkCompat") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun signInWithPhoneNumber(request: SignInWithPhoneNumberAidlRequest, callbacks: IFirebaseAuthCallbacks) { + lifecycleScope.launchWhenStarted { + Log.d(TAG, "signInWithPhoneNumber") + try { + val tokenResult = client.verifyPhoneNumber( + phoneNumber = request.credential.phoneNumber, + temporaryProof = request.credential.temporaryProof, + sessionInfo = request.credential.sessionInfo, + code = request.credential.smsCode + ) + val idToken = tokenResult.getString("idToken") + val refreshToken = tokenResult.getString("refreshToken") + val isNewUser = tokenResult.optBoolean("isNewUser") + val getTokenResponse = client.getTokenByRefreshToken(refreshToken).toGetTokenResponse() + val accountInfoResult = client.getAccountInfo(idToken).getJSONArray("users").getJSONObject(0).toGetAccountInfoUser().apply { this.isNewUser = isNewUser } + Log.d(TAG, "callback: onGetTokenResponseAndUser") + callbacks.onGetTokenResponseAndUser(getTokenResponse, accountInfoResult) + } catch (e: Exception) { + Log.w(TAG, "callback: onFailure", e) + callbacks.onFailure(Status(CommonStatusCodes.INTERNAL_ERROR, e.message)) + } + } + } + + override fun signInWithPhoneNumberCompat(credential: PhoneAuthCredential?, callbacks: IFirebaseAuthCallbacks) { + signInWithPhoneNumber(SignInWithPhoneNumberAidlRequest().apply { this.credential = credential }, callbacks) + } + + override fun startMfaEnrollmentWithPhoneNumber(request: StartMfaPhoneNumberEnrollmentAidlRequest, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: startMfaEnrollmentWithPhoneNumber") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun startMfaSignInWithPhoneNumber(request: StartMfaPhoneNumberSignInAidlRequest, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: startMfaSignInWithPhoneNumber") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun unenrollMfa(request: UnenrollMfaAidlRequest, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: unenrollMfa") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun unlinkEmailCredential(request: UnlinkEmailCredentialAidlRequest, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: unlinkEmailCredential") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun unlinkEmailCredentialCompat(cachedState: String?, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: unlinkEmailCredentialCompat") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun unlinkFederatedCredential(request: UnlinkFederatedCredentialAidlRequest, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: unlinkFederatedCredential") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun unlinkFederatedCredentialCompat(provider: String?, cachedState: String?, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: unlinkFederatedCredentialCompat") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + override fun updateProfile(request: UpdateProfileAidlRequest, callbacks: IFirebaseAuthCallbacks) { + lifecycleScope.launchWhenStarted { + Log.d(TAG, "updateProfile") + try { + val getTokenResponse = refreshTokenResponse(request.cachedState) + val accountInfoResult = client.getAccountInfo(idToken = getTokenResponse.accessToken).getJSONArray("users").getJSONObject(0).toGetAccountInfoUser() + val setAccountInfo = client.setAccountInfo(idToken = getTokenResponse.accessToken, localId = accountInfoResult.localId, displayName = request.request.displayName, photoUrl = request.request.photoUrl, deleteAttribute = request.request.deleteAttributeList).toGetAccountInfoUser() + accountInfoResult.photoUrl = setAccountInfo.photoUrl + accountInfoResult.displayName = setAccountInfo.displayName + callbacks.onGetTokenResponseAndUser(getTokenResponse, accountInfoResult) + } catch (e: Exception) { + Log.w(TAG, "callback: onFailure", e) + callbacks.onFailure(Status(CommonStatusCodes.INTERNAL_ERROR, e.message)) + } + } + } + + override fun updateProfileCompat(cachedState: String?, userProfileChangeRequest: UserProfileChangeRequest, callbacks: IFirebaseAuthCallbacks) { + updateProfile(UpdateProfileAidlRequest().apply { this.cachedState = cachedState; this.request = userProfileChangeRequest}, callbacks) + } + + override fun verifyBeforeUpdateEmail(request: VerifyBeforeUpdateEmailAidlRequest, callbacks: IFirebaseAuthCallbacks) { + Log.d(TAG, "Not yet implemented: verifyBeforeUpdateEmail") + callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported")) + } + + + override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean { + if (super.onTransact(code, data, reply, flags)) return true + Log.d(TAG, "onTransact: $code, $data, $flags") + return false + } +} diff --git a/firebase-auth-core/src/main/kotlin/org/microg/gms/firebase/auth/IdentityToolkitClient.kt b/firebase-auth-core/src/main/kotlin/org/microg/gms/firebase/auth/IdentityToolkitClient.kt new file mode 100644 index 00000000..459feb1f --- /dev/null +++ b/firebase-auth-core/src/main/kotlin/org/microg/gms/firebase/auth/IdentityToolkitClient.kt @@ -0,0 +1,139 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.microg.gms.firebase.auth + +import android.content.Context +import android.util.Log +import com.android.volley.NetworkResponse +import com.android.volley.ParseError +import com.android.volley.Request.Method.GET +import com.android.volley.Request.Method.POST +import com.android.volley.Response +import com.android.volley.VolleyError +import com.android.volley.toolbox.HttpHeaderParser +import com.android.volley.toolbox.JsonObjectRequest +import com.android.volley.toolbox.JsonRequest +import com.android.volley.toolbox.Volley +import org.json.JSONArray +import org.json.JSONException +import org.json.JSONObject +import java.io.UnsupportedEncodingException +import java.lang.RuntimeException +import java.nio.charset.Charset +import kotlin.coroutines.resume +import kotlin.coroutines.resumeWithException +import kotlin.coroutines.suspendCoroutine + +private const val TAG = "GmsFirebaseAuthClient" + +class IdentityToolkitClient(context: Context, private val apiKey: String) { + private val queue = Volley.newRequestQueue(context) + + private fun buildRelyingPartyUrl(method: String) = "https://www.googleapis.com/identitytoolkit/v3/relyingparty/$method?key=$apiKey" + private fun buildStsUrl(method: String) = "https://securetoken.googleapis.com/v1/$method?key=$apiKey" + + private suspend fun request(method: String, data: JSONObject): JSONObject = suspendCoroutine { continuation -> + queue.add(JsonObjectRequest(POST, buildRelyingPartyUrl(method), data, { + continuation.resume(it) + }, { + Log.d(TAG, String(it.networkResponse.data)) + continuation.resumeWithException(RuntimeException(it)) + })) + } + + suspend fun createAuthUri(identifier: String? = null, tenantId: String? = null, continueUri: String? = "http://localhost"): JSONObject = + request("createAuthUri", JSONObject() + .put("identifier", identifier) + .put("tenantId", tenantId) + .put("continueUri", continueUri)) + + suspend fun getAccountInfo(idToken: String? = null): JSONObject = + request("getAccountInfo", JSONObject() + .put("idToken", idToken)) + + suspend fun getProjectConfig(): JSONObject = suspendCoroutine { continuation -> + queue.add(JsonObjectRequest(GET, buildRelyingPartyUrl("getProjectConfig"), null, { continuation.resume(it) }, { continuation.resumeWithException(RuntimeException(it)) })) + } + + suspend fun getOobConfirmationCode(requestType: String, email: String? = null, newEmail: String? = null, continueUrl: String? = null, idToken: String? = null, iOSBundleId: String? = null, iOSAppStoreId: String? = null, androidMinimumVersion: String? = null, androidInstallApp: Boolean? = null, androidPackageName: String? = null, canHandleCodeInApp: Boolean? = null): JSONObject = + request("getOobConfirmationCode", JSONObject() + .put("kind", "identitytoolkit#relyingparty") + .put("requestType", requestType) + .put("email", email) + .put("newEmail", newEmail) + .put("continueUrl", continueUrl) + .put("idToken", idToken) + .put("iOSBundleId", iOSBundleId) + .put("iOSAppStoreId", iOSAppStoreId) + .put("androidMinimumVersion", androidMinimumVersion) + .put("androidInstallApp", androidInstallApp) + .put("androidPackageName", androidPackageName) + .put("canHandleCodeInApp", canHandleCodeInApp)) + + + suspend fun sendVerificationCode(phoneNumber: String? = null, reCaptchaToken: String? = null): JSONObject = + request("sendVerificationCode", JSONObject() + .put("phoneNumber", phoneNumber) + .put("recaptchaToken", reCaptchaToken)) + + suspend fun setAccountInfo(idToken: String? = null, localId: String? = null, email: String? = null, password: String? = null, displayName: String? = null, photoUrl: String? = null, deleteAttribute: List = emptyList()): JSONObject = + request("setAccountInfo", JSONObject() + .put("idToken", idToken) + .put("localId", localId) + .put("email", email) + .put("password", password) + .put("displayName", displayName) + .put("photoUrl", photoUrl) + .put("deleteAttribute", JSONArray().apply { deleteAttribute.forEach { put(it) } })) + + suspend fun signupNewUser(email: String? = null, password: String? = null, tenantId: String? = null): JSONObject = + request("signupNewUser", JSONObject() + .put("email", email) + .put("password", password) + .put("tenantId", tenantId)) + + suspend fun verifyCustomToken(token: String? = null, returnSecureToken: Boolean = true): JSONObject = + request("verifyCustomToken", JSONObject() + .put("token", token) + .put("returnSecureToken", returnSecureToken)) + + suspend fun verifyPassword(email: String? = null, password: String? = null, tenantId: String? = null, returnSecureToken: Boolean = true): JSONObject = + request("verifyPassword", JSONObject() + .put("email", email) + .put("password", password) + .put("tenantId", tenantId) + .put("returnSecureToken", returnSecureToken)) + + suspend fun verifyPhoneNumber(phoneNumber: String? = null, sessionInfo: String? = null, code: String? = null, idToken: String? = null, verificationProof: String? = null, temporaryProof: String? = null): JSONObject = + request("verifyPhoneNumber", JSONObject() + .put("verificationProof", verificationProof) + .put("code", code) + .put("idToken", idToken) + .put("temporaryProof", temporaryProof) + .put("phoneNumber", phoneNumber) + .put("sessionInfo", sessionInfo)) + + suspend fun getTokenByRefreshToken(refreshToken: String): JSONObject = suspendCoroutine { continuation -> + queue.add(StsRequest(POST, buildStsUrl("token"), "grant_type=refresh_token&refresh_token=$refreshToken", { continuation.resume(it) }, { continuation.resumeWithException(RuntimeException(it)) })) + } +} + +private class StsRequest(method: Int, url: String, request: String?, listener: (JSONObject) -> Unit, errorListener: (VolleyError) -> Unit) : JsonRequest(method, url, request, listener, errorListener) { + override fun parseNetworkResponse(response: NetworkResponse?): Response { + return try { + val jsonString = String(response!!.data, Charset.forName(HttpHeaderParser.parseCharset(response!!.headers, PROTOCOL_CHARSET))) + Response.success(JSONObject(jsonString), HttpHeaderParser.parseCacheHeaders(response)) + } catch (e: UnsupportedEncodingException) { + Response.error(ParseError(e)) + } catch (je: JSONException) { + Response.error(ParseError(je)) + } + } + + override fun getBodyContentType(): String { + return "application/x-www-form-urlencoded" + } +} diff --git a/firebase-auth-core/src/main/kotlin/org/microg/gms/firebase/auth/ReCaptchaActivity.kt b/firebase-auth-core/src/main/kotlin/org/microg/gms/firebase/auth/ReCaptchaActivity.kt new file mode 100644 index 00000000..784d4298 --- /dev/null +++ b/firebase-auth-core/src/main/kotlin/org/microg/gms/firebase/auth/ReCaptchaActivity.kt @@ -0,0 +1,103 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.microg.gms.firebase.auth + +import android.annotation.SuppressLint +import android.app.Activity +import android.content.Context +import android.content.Intent +import android.content.Intent.* +import android.os.Bundle +import android.os.ResultReceiver +import android.util.Log +import android.webkit.JavascriptInterface +import android.webkit.WebSettings +import android.webkit.WebView +import androidx.appcompat.app.AppCompatActivity +import org.microg.gms.firebase.auth.core.R +import kotlin.coroutines.resume +import kotlin.coroutines.resumeWithException +import kotlin.coroutines.suspendCoroutine + +private const val TAG = "GmsFirebaseAuthCaptcha" + +class ReCaptchaActivity : AppCompatActivity() { + private val receiver: ResultReceiver? + get() = intent.getParcelableExtra(EXTRA_RESULT_RECEIVER) + private val hostname: String + get() = intent.getStringExtra(EXTRA_HOSTNAME) ?: "localhost:5000" + private var finished = false + + @SuppressLint("SetJavaScriptEnabled", "AddJavascriptInterface") + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + openWebsite() + } + + private fun openWebsite() { + val apiKey = intent.getStringExtra(EXTRA_API_KEY) ?: return finishResult(Activity.RESULT_CANCELED) + setContentView(R.layout.activity_recaptcha) + val view = findViewById(R.id.web) + val settings = view.settings + settings.javaScriptEnabled = true + settings.useWideViewPort = false + settings.setSupportZoom(false) + settings.displayZoomControls = false + settings.cacheMode = WebSettings.LOAD_NO_CACHE + view.addJavascriptInterface(object : Any() { + @JavascriptInterface + fun onReCaptchaToken(token: String) { + Log.d(TAG, "onReCaptchaToken: $token") + finishResult(Activity.RESULT_OK, token) + } + }, "MyCallback") + val captcha = assets.open("recaptcha.html").bufferedReader().readText().replace("%apikey%", apiKey) + view.loadDataWithBaseURL("https://$hostname/", captcha, null, null, "https://$hostname/") + } + + fun finishResult(resultCode: Int, token: String? = null) { + finished = true + setResult(resultCode, token?.let { Intent().apply { putExtra(EXTRA_TOKEN, it) } }) + receiver?.send(resultCode, token?.let { Bundle().apply { putString(EXTRA_TOKEN, it) } }) + finish() + } + + override fun onDestroy() { + super.onDestroy() + if (!finished) receiver?.send(Activity.RESULT_CANCELED, null) + } + + companion object { + const val EXTRA_TOKEN = "token" + const val EXTRA_API_KEY = "api_key" + const val EXTRA_HOSTNAME = "hostname" + const val EXTRA_RESULT_RECEIVER = "receiver" + + fun isSupported(context: Context): Boolean = true + + suspend fun awaitToken(context: Context, apiKey: String, hostname: String? = null) = suspendCoroutine { continuation -> + val intent = Intent(context, ReCaptchaActivity::class.java) + val resultReceiver = object : ResultReceiver(null) { + override fun onReceiveResult(resultCode: Int, resultData: Bundle?) { + try { + if (resultCode == Activity.RESULT_OK) { + continuation.resume(resultData?.getString(EXTRA_TOKEN)!!) + } + } catch (e: Exception) { + continuation.resumeWithException(e) + } + } + } + intent.putExtra(EXTRA_API_KEY, apiKey) + intent.putExtra(EXTRA_RESULT_RECEIVER, resultReceiver) + intent.putExtra(EXTRA_HOSTNAME, hostname) + intent.addFlags(FLAG_ACTIVITY_NEW_TASK) + intent.addFlags(FLAG_ACTIVITY_REORDER_TO_FRONT) + intent.addFlags(FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) + context.startActivity(intent) + } + } +} diff --git a/firebase-auth-core/src/main/kotlin/org/microg/gms/firebase/auth/ReCaptchaOverlay.kt b/firebase-auth-core/src/main/kotlin/org/microg/gms/firebase/auth/ReCaptchaOverlay.kt new file mode 100644 index 00000000..5af19c68 --- /dev/null +++ b/firebase-auth-core/src/main/kotlin/org/microg/gms/firebase/auth/ReCaptchaOverlay.kt @@ -0,0 +1,119 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.microg.gms.firebase.auth + +import android.content.Context +import android.graphics.PixelFormat +import android.os.Build +import android.provider.Settings +import android.util.DisplayMetrics +import android.util.Log +import android.view.* +import android.webkit.JavascriptInterface +import android.webkit.WebSettings +import android.webkit.WebView +import android.widget.FrameLayout +import org.microg.gms.firebase.auth.core.R +import kotlin.coroutines.Continuation +import kotlin.coroutines.resume +import kotlin.coroutines.resumeWithException +import kotlin.coroutines.suspendCoroutine + + +private const val TAG = "GmsFirebaseAuthCaptcha" + +class ReCaptchaOverlay(val context: Context, val apiKey: String, val hostname: String?, val continuation: Continuation) { + + val windowManager = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager + var finished = false + var container: View? = null + + private fun show() { + val layoutParamsType = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY + } else { + WindowManager.LayoutParams.TYPE_SYSTEM_ALERT + } + + val params = WindowManager.LayoutParams( + WindowManager.LayoutParams.MATCH_PARENT, + WindowManager.LayoutParams.WRAP_CONTENT, + layoutParamsType, + 0, + PixelFormat.TRANSLUCENT) + + params.gravity = Gravity.CENTER or Gravity.START + params.x = 0 + params.y = 0 + + val interceptorLayout: FrameLayout = object : FrameLayout(context) { + override fun dispatchKeyEvent(event: KeyEvent): Boolean { + if (event.action == KeyEvent.ACTION_DOWN) { + if (event.keyCode == KeyEvent.KEYCODE_BACK || event.keyCode == KeyEvent.KEYCODE_HOME) { + cancel() + return true + } + } + return super.dispatchKeyEvent(event) + } + } + + val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as? LayoutInflater? + if (inflater != null) { + val container = inflater.inflate(R.layout.activity_recaptcha, interceptorLayout) + this.container = container + container.setBackgroundResource(androidx.appcompat.R.drawable.abc_dialog_material_background) + val pad = (5.0 * (context.resources.displayMetrics.densityDpi.toFloat() / DisplayMetrics.DENSITY_DEFAULT)).toInt() + container.setOnTouchListener { v, _ -> + v.performClick() + cancel() + return@setOnTouchListener true + } + val view = container.findViewById(R.id.web) + view.setPadding(pad, pad, pad, pad) + val settings = view.settings + settings.javaScriptEnabled = true + settings.useWideViewPort = false + settings.setSupportZoom(false) + settings.displayZoomControls = false + settings.cacheMode = WebSettings.LOAD_NO_CACHE + view.addJavascriptInterface(object : Any() { + @JavascriptInterface + fun onReCaptchaToken(token: String) { + Log.d(TAG, "onReCaptchaToken: $token") + if (!finished) { + finished = true + continuation.resume(token) + } + close() + } + }, "MyCallback") + val captcha = context.assets.open("recaptcha.html").bufferedReader().readText().replace("%apikey%", apiKey) + view.loadDataWithBaseURL("https://$hostname/", captcha, null, null, "https://$hostname/") + windowManager.addView(container, params) + } + } + + fun cancel() { + if (!finished) { + finished = true + continuation.resumeWithException(RuntimeException("User cancelled")) + } + close() + } + + fun close() { + container?.let { windowManager.removeView(it) } + } + + companion object { + fun isSupported(context: Context): Boolean = Build.VERSION.SDK_INT < Build.VERSION_CODES.M || Settings.canDrawOverlays(context) + + suspend fun awaitToken(context: Context, apiKey: String, hostname: String? = null) = suspendCoroutine { continuation -> + ReCaptchaOverlay(context, apiKey, hostname ?: "localhost:5000", continuation).show() + } + } +} diff --git a/firebase-auth-core/src/main/res/layout/activity_recaptcha.xml b/firebase-auth-core/src/main/res/layout/activity_recaptcha.xml new file mode 100644 index 00000000..36ea80bb --- /dev/null +++ b/firebase-auth-core/src/main/res/layout/activity_recaptcha.xml @@ -0,0 +1,19 @@ + + + + + + + diff --git a/play-services-base-core-ui/src/main/res/values/layout.xml b/play-services-base-core-ui/src/main/res/values/themes.xml similarity index 66% rename from play-services-base-core-ui/src/main/res/values/layout.xml rename to play-services-base-core-ui/src/main/res/values/themes.xml index a70af9e5..a32388e2 100644 --- a/play-services-base-core-ui/src/main/res/values/layout.xml +++ b/play-services-base-core-ui/src/main/res/values/themes.xml @@ -6,6 +6,11 @@ + +