diff options
Diffstat (limited to 'Firebase/Auth')
102 files changed, 1118 insertions, 228 deletions
diff --git a/Firebase/Auth/FirebaseAuth.podspec b/Firebase/Auth/FirebaseAuth.podspec index 3d7eb2f..4d522aa 100644 --- a/Firebase/Auth/FirebaseAuth.podspec +++ b/Firebase/Auth/FirebaseAuth.podspec @@ -36,6 +36,9 @@ Simplify your iOS development, grow your user base, and monetize more effectivel s.preserve_paths = 'README.md', 'CHANGELOG.md' + s.resource_bundle = { + 'FirebaseAuth' => 'Source/FirebaseAuth.bundle/**/*.strings' + } s.xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) ' + 'FIRAuth_VERSION=' + s.version.to_s + ' FIRAuth_MINOR_VERSION=' + s.version.to_s.split(".")[0] + "." + s.version.to_s.split(".")[1] diff --git a/Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthProvider.m b/Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthProvider.m index f950b72..7a5cc0f 100644 --- a/Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthProvider.m +++ b/Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthProvider.m @@ -131,8 +131,8 @@ typedef void (^FIRVerifyClientCallback)(FIRAuthAppCredential *_Nullable appCrede } FIRSendVerificationCodeRequest *request = [[FIRSendVerificationCodeRequest alloc] initWithPhoneNumber:phoneNumber - appCredential:appCredential - APIKey:_auth.APIKey]; + appCredential:appCredential + requestConfiguration:_auth.requestConfiguration]; [FIRAuthBackend sendVerificationCode:request callback:^(FIRSendVerificationCodeResponse *_Nullable response, NSError *_Nullable error) { @@ -185,7 +185,7 @@ typedef void (^FIRVerifyClientCallback)(FIRAuthAppCredential *_Nullable appCrede FIRVerifyClientRequest *request = [[FIRVerifyClientRequest alloc] initWithAppToken:tokenString isSandbox:token.type == FIRAuthAPNSTokenTypeSandbox - APIKey:_auth.APIKey]; + requestConfiguration:_auth.requestConfiguration]; [FIRAuthBackend verifyClient:request callback:^(FIRVerifyClientResponse *_Nullable response, NSError *_Nullable error) { if (error) { diff --git a/Firebase/Auth/Source/FIRActionCodeSettings.m b/Firebase/Auth/Source/FIRActionCodeSettings.m new file mode 100644 index 0000000..13aa318 --- /dev/null +++ b/Firebase/Auth/Source/FIRActionCodeSettings.m @@ -0,0 +1,37 @@ +/* + * Copyright 2017 Google + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + #import "FIRActionCodeSettings.h" + + NS_ASSUME_NONNULL_BEGIN + + @implementation FIRActionCodeSettings + +- (void)setIOSBundleID:(NSString *)iOSBundleID { + _iOSBundleID = [iOSBundleID copy]; + } + +- (void)setAndroidPackageName:(NSString *)androidPackageName + installIfNotAvailable:(BOOL)installIfNotAvailable + minimumVersion:(nullable NSString *)minimumVersion { + _androidPackageName = [androidPackageName copy]; + _androidInstallIfNotAvailable = installIfNotAvailable; + _androidMinimumVersion = [minimumVersion copy]; + } + + @end + + NS_ASSUME_NONNULL_END diff --git a/Firebase/Auth/Source/FIRAuth.m b/Firebase/Auth/Source/FIRAuth.m index 5e2e9a2..f1e1071 100644 --- a/Firebase/Auth/Source/FIRAuth.m +++ b/Firebase/Auth/Source/FIRAuth.m @@ -34,6 +34,7 @@ #import "FIRUser_Internal.h" #import "FirebaseAuth.h" #import "FIRAuthBackend.h" +#import "FIRAuthRequestConfiguration.h" #import "FIRCreateAuthURIRequest.h" #import "FIRCreateAuthURIResponse.h" #import "FIRGetOOBConfirmationCodeRequest.h" @@ -97,10 +98,18 @@ NSTimeInterval kTokenRefreshHeadStart = 5 * 60; static NSString *const kUserKey = @"%@_firebase_user"; /** @var kMissingEmailInvalidParameterExceptionReason - @brief The key of missing email key @c invalidParameterException. + @brief The reason for @c invalidParameterException when the email used to initiate password + reset is nil. */ -static NSString *const kEmailInvalidParameterReason = @"The email used to initiate password reset " - "cannot be nil"; +static NSString *const kMissingEmailInvalidParameterExceptionReason = + @"The email used to initiate password reset cannot be nil."; + +/** @var kMissingLocaleBundleInvalidParameterExceptionReason + @brief The reason for @c invalidParameterException when the locale bundle is missing. + */ +static NSString *const kMissingLocaleBundleInvalidParameterExceptionReason = + @"The bundle used to obtain the current device language is missing. Please ensure that" + " %@.bundle is included as part of Firebase Auth."; static NSString *const kPasswordResetRequestType = @"PASSWORD_RESET"; @@ -112,6 +121,21 @@ static NSString *const kVerifyEmailRequestType = @"VERIFY_EMAIL"; */ static NSString *const kMissingPasswordReason = @"Missing Password"; +/** @var kFirebaseAuthBundleFileName + @brief The name of the Firebase Auth bundle file. + */ +static NSString *const kFirebaseAuthBundleFileName = @"FirebaseAuth"; + +/** @var kFirebaseLocalizedStringKey + @brief The key for the Firebase locale langauge code. + */ +static NSString *const kFirebaseLocaleStringKey = @"FIREBASE_LOCALE_STRING"; + +/** @var kFirebaseLocaleTabe + @brief The table from which we obtain the Firebase language code. + */ +static NSString *const kFirebaseLocaleTabe = @"FirebaseLocale"; + /** @var gKeychainServiceNameForAppName @brief A map from Firebase app name to keychain service names. @remarks This map is needed for looking up the keychain service name after the FIRApp instance @@ -384,7 +408,7 @@ static NSMutableDictionary *gKeychainServiceNameForAppName; self = [super init]; if (self) { _listenerHandles = [NSMutableArray array]; - _APIKey = [APIKey copy]; + _requestConfiguration = [[FIRAuthRequestConfiguration alloc] initWithAPIKey:APIKey]; _firebaseAppName = [appName copy]; #if TARGET_OS_IOS UIApplication *application = [UIApplication sharedApplication]; @@ -469,7 +493,7 @@ static NSMutableDictionary *gKeychainServiceNameForAppName; FIRCreateAuthURIRequest *request = [[FIRCreateAuthURIRequest alloc] initWithIdentifier:email continueURI:@"http://www.google.com/" - APIKey:_APIKey]; + requestConfiguration:_requestConfiguration]; [FIRAuthBackend createAuthURI:request callback:^(FIRCreateAuthURIResponse *_Nullable response, NSError *_Nullable error) { if (completion) { @@ -504,7 +528,9 @@ static NSMutableDictionary *gKeychainServiceNameForAppName; password:(NSString *)password callback:(FIRAuthResultCallback)callback { FIRVerifyPasswordRequest *request = - [[FIRVerifyPasswordRequest alloc] initWithEmail:email password:password APIKey:_APIKey]; + [[FIRVerifyPasswordRequest alloc] initWithEmail:email + password:password + requestConfiguration:_requestConfiguration]; if (![request.password length]) { callback(nil, [FIRAuthErrorUtils wrongPasswordErrorWithMessage:nil]); @@ -589,9 +615,9 @@ static NSMutableDictionary *gKeychainServiceNameForAppName; return; } #endif - FIRVerifyAssertionRequest *request = - [[FIRVerifyAssertionRequest alloc] initWithAPIKey:_APIKey providerID:credential.provider]; + [[FIRVerifyAssertionRequest alloc] initWithProviderID:credential.provider + requestConfiguration:_requestConfiguration]; request.autoCreate = !isReauthentication; [credential prepareVerifyAssertionRequest:request]; [FIRAuthBackend verifyAssertion:request @@ -651,7 +677,8 @@ static NSMutableDictionary *gKeychainServiceNameForAppName; decoratedCallback(_currentUser, nil); return; } - FIRSignUpNewUserRequest *request = [[FIRSignUpNewUserRequest alloc] initWithAPIKey:_APIKey]; + FIRSignUpNewUserRequest *request = + [[FIRSignUpNewUserRequest alloc]initWithRequestConfiguration:_requestConfiguration]; [FIRAuthBackend signUpNewUser:request callback:^(FIRSignUpNewUserResponse *_Nullable response, NSError *_Nullable error) { @@ -674,7 +701,8 @@ static NSMutableDictionary *gKeychainServiceNameForAppName; FIRAuthResultCallback decoratedCallback = [self signInFlowAuthResultCallbackByDecoratingCallback:completion]; FIRVerifyCustomTokenRequest *request = - [[FIRVerifyCustomTokenRequest alloc] initWithToken:token APIKey:_APIKey]; + [[FIRVerifyCustomTokenRequest alloc] initWithToken:token + requestConfiguration:_requestConfiguration]; [FIRAuthBackend verifyCustomToken:request callback:^(FIRVerifyCustomTokenResponse *_Nullable response, NSError *_Nullable error) { @@ -697,10 +725,11 @@ static NSMutableDictionary *gKeychainServiceNameForAppName; dispatch_async(FIRAuthGlobalWorkQueue(), ^{ FIRAuthResultCallback decoratedCallback = [self signInFlowAuthResultCallbackByDecoratingCallback:completion]; - FIRSignUpNewUserRequest *request = [[FIRSignUpNewUserRequest alloc] initWithAPIKey:_APIKey - email:email - password:password - displayName:nil]; + FIRSignUpNewUserRequest *request = + [[FIRSignUpNewUserRequest alloc] initWithEmail:email + password:password + displayName:nil + requestConfiguration:_requestConfiguration]; if (![request.password length]) { decoratedCallback(nil, [FIRAuthErrorUtils weakPasswordErrorWithServerResponseReason:kMissingPasswordReason]); @@ -731,9 +760,9 @@ static NSMutableDictionary *gKeychainServiceNameForAppName; completion:(FIRConfirmPasswordResetCallback)completion { dispatch_async(FIRAuthGlobalWorkQueue(), ^{ FIRResetPasswordRequest *request = - [[FIRResetPasswordRequest alloc] initWithAPIKey:_APIKey - oobCode:code - newPassword:newPassword]; + [[FIRResetPasswordRequest alloc] initWithOobCode:code + newPassword:newPassword + requestConfiguration:_requestConfiguration]; [FIRAuthBackend resetPassword:request callback:^(FIRResetPasswordResponse *_Nullable response, NSError *_Nullable error) { if (completion) { @@ -752,9 +781,9 @@ static NSMutableDictionary *gKeychainServiceNameForAppName; - (void)checkActionCode:(NSString *)code completion:(FIRCheckActionCodeCallBack)completion { dispatch_async(FIRAuthGlobalWorkQueue(), ^ { FIRResetPasswordRequest *request = - [[FIRResetPasswordRequest alloc] initWithAPIKey:_APIKey - oobCode:code - newPassword:nil]; + [[FIRResetPasswordRequest alloc] initWithOobCode:code + newPassword:nil + requestConfiguration:_requestConfiguration]; [FIRAuthBackend resetPassword:request callback:^(FIRResetPasswordResponse *_Nullable response, NSError *_Nullable error) { if (completion) { @@ -794,7 +823,8 @@ static NSMutableDictionary *gKeychainServiceNameForAppName; - (void)applyActionCode:(NSString *)code completion:(FIRApplyActionCodeCallback)completion { dispatch_async(FIRAuthGlobalWorkQueue(), ^ { - FIRSetAccountInfoRequest *request = [[FIRSetAccountInfoRequest alloc]initWithAPIKey:_APIKey]; + FIRSetAccountInfoRequest *request = + [[FIRSetAccountInfoRequest alloc] initWithRequestConfiguration:_requestConfiguration]; request.OOBCode = code; [FIRAuthBackend setAccountInfo:request callback:^(FIRSetAccountInfoResponse *_Nullable response, NSError *_Nullable error) { @@ -809,12 +839,40 @@ static NSMutableDictionary *gKeychainServiceNameForAppName; - (void)sendPasswordResetWithEmail:(NSString *)email completion:(nullable FIRSendPasswordResetCallback)completion { + [self sendPasswordResetWithNullableActionCodeSettings:nil email:email completion:completion]; +} + +- (void)sendPasswordResetWithEmail:(NSString *)email + actionCodeSettings:(FIRActionCodeSettings *)actionCodeSettings + completion:(nullable FIRSendPasswordResetCallback)completion { + [self sendPasswordResetWithNullableActionCodeSettings:actionCodeSettings + email:email + completion:completion]; +} + +/** @fn sendPasswordResetWithNullableActionCodeSettings:actionCodeSetting:email:completion: + @brief Initiates a password reset for the given email address and @FIRActionCodeSettings object. + + @param actionCodeSettings Optionally, An @c FIRActionCodeSettings object containing settings + related to the handling action codes. + @param email The email address of the user. + @param completion Optionally; a block which is invoked when the request finishes. Invoked + asynchronously on the main thread in the future. + */ +- (void)sendPasswordResetWithNullableActionCodeSettings:(nullable FIRActionCodeSettings *) + actionCodeSettings + email:(NSString *)email + completion:(nullable FIRSendPasswordResetCallback) + completion { dispatch_async(FIRAuthGlobalWorkQueue(), ^{ if (!email) { - [FIRAuthExceptionUtils raiseInvalidParameterExceptionWithReason:kEmailInvalidParameterReason]; + [FIRAuthExceptionUtils raiseInvalidParameterExceptionWithReason: + kMissingEmailInvalidParameterExceptionReason]; } FIRGetOOBConfirmationCodeRequest *request = - [FIRGetOOBConfirmationCodeRequest passwordResetRequestWithEmail:email APIKey:_APIKey]; + [FIRGetOOBConfirmationCodeRequest passwordResetRequestWithEmail:email + actionCodeSettings:actionCodeSettings + requestConfiguration:_requestConfiguration]; [FIRAuthBackend getOOBConfirmationCode:request callback:^(FIRGetOOBConfirmationCodeResponse *_Nullable response, NSError *_Nullable error) { @@ -895,6 +953,25 @@ static NSMutableDictionary *gKeychainServiceNameForAppName; } } +- (void)useAppLanguage { + NSString *path = + [[NSBundle bundleForClass:[self class]] pathForResource:kFirebaseAuthBundleFileName + ofType:@"bundle"]; + NSBundle *bundle; + bundle = [NSBundle bundleWithPath:path]; + if (!bundle) { + NSString *reason = [NSString stringWithFormat:kMissingLocaleBundleInvalidParameterExceptionReason, + kFirebaseAuthBundleFileName]; + [FIRAuthExceptionUtils raiseInvalidParameterExceptionWithReason:reason]; + } + _requestConfiguration.languageCode = + [bundle localizedStringForKey:kFirebaseLocaleStringKey value:nil table:@"FirebaseLocale"]; +} + +- (NSString *)languageCode { + return _requestConfiguration.languageCode; +} + #if TARGET_OS_IOS - (NSData *)APNSToken { __block NSData *result = nil; @@ -925,6 +1002,10 @@ static NSMutableDictionary *gKeychainServiceNameForAppName; #pragma mark - Internal Methods +- (void)setLanguageCode:(NSString *)languageCode { + _requestConfiguration.languageCode = [languageCode copy]; +} + #if TARGET_OS_IOS /** @fn signInWithPhoneCredential:callback: @brief Signs in using a phone credential. @@ -938,7 +1019,7 @@ static NSMutableDictionary *gKeychainServiceNameForAppName; FIRVerifyPhoneNumberRequest *request = [[FIRVerifyPhoneNumberRequest alloc] initWithTemporaryProof:credential.temporaryProof phoneNumber:credential.phoneNumber - APIKey:_APIKey]; + requestConfiguration:_requestConfiguration]; [self phoneNumberSignInWithRequest:request callback:callback]; return; } @@ -954,7 +1035,7 @@ static NSMutableDictionary *gKeychainServiceNameForAppName; FIRVerifyPhoneNumberRequest *request = [[FIRVerifyPhoneNumberRequest alloc]initWithVerificationID:credential.verificationID verificationCode:credential.verificationCode - APIKey:_APIKey]; + requestConfiguration:_requestConfiguration]; [self phoneNumberSignInWithRequest:request callback:callback]; } @@ -1138,7 +1219,7 @@ static NSMutableDictionary *gKeychainServiceNameForAppName; refreshToken:(NSString *)refreshToken anonymous:(BOOL)anonymous callback:(FIRAuthResultCallback)callback { - [FIRUser retrieveUserWithAPIKey:_APIKey + [FIRUser retrieveUserWithAPIKey:_requestConfiguration.APIKey accessToken:accessToken accessTokenExpirationDate:accessTokenExpirationDate refreshToken:refreshToken diff --git a/Firebase/Auth/Source/FIRAuthErrorUtils.h b/Firebase/Auth/Source/FIRAuthErrorUtils.h index e8eb1f5..1dde98f 100644 --- a/Firebase/Auth/Source/FIRAuthErrorUtils.h +++ b/Firebase/Auth/Source/FIRAuthErrorUtils.h @@ -313,6 +313,41 @@ NS_ASSUME_NONNULL_BEGIN */ + (NSError *)invalidRecipientEmailErrorWithMessage:(nullable NSString *)message; +/** @fn missingIosBundleIDErrorWithMessage: + @brief Constructs an @c NSError with the @c FIRAuthErrorCodeMissingIosBundleID code. + @param message Error message from the backend, if any. + @return The NSError instance associated with the given FIRAuthError. + */ ++ (NSError *)missingIosBundleIDErrorWithMessage:(nullable NSString *)message; + +/** @fn missingAndroidPackageNameErrorWithMessage: + @brief Constructs an @c NSError with the @c FIRAuthErrorCodeMissingAndroidPackageName code. + @param message Error message from the backend, if any. + @return The NSError instance associated with the given FIRAuthError. + */ ++ (NSError *)missingAndroidPackageNameErrorWithMessage:(nullable NSString *)message; + +/** @fn unauthorizedDomainErrorWithMessage: + @brief Constructs an @c NSError with the @c FIRAuthErrorCodeUnauthorizedDomain code. + @param message Error message from the backend, if any. + @return The NSError instance associated with the given FIRAuthError. + */ ++ (NSError *)unauthorizedDomainErrorWithMessage:(nullable NSString *)message; + +/** @fn invalidContinueURIErrorWithMessage: + @brief Constructs an @c NSError with the @c FIRAuthErrorCodeInvalidContinueURI code. + @param message Error message from the backend, if any. + @return The NSError instance associated with the given FIRAuthError. + */ ++ (NSError *)invalidContinueURIErrorWithMessage:(nullable NSString *)message; + +/** @fn missingContinueURIErrorWithMessage: + @brief Constructs an @c NSError with the @c FIRAuthErrorCodeMissingContinueURI code. + @param message Error message from the backend, if any. + @return The NSError instance associated with the given FIRAuthError. + */ ++ (NSError *)missingContinueURIErrorWithMessage:(nullable NSString *)message; + /** @fn missingEmail @brief Constructs an @c NSError with the @c FIRAuthErrorCodeMissingEmail code. @return The NSError instance associated with the given FIRAuthError. diff --git a/Firebase/Auth/Source/FIRAuthErrorUtils.m b/Firebase/Auth/Source/FIRAuthErrorUtils.m index 671eac6..b320cf9 100644 --- a/Firebase/Auth/Source/FIRAuthErrorUtils.m +++ b/Firebase/Auth/Source/FIRAuthErrorUtils.m @@ -217,6 +217,30 @@ static NSString *const kFIRAuthErrorMessageInvalidSender = @"The email template static NSString *const kFIRAuthErrorMessageInvalidRecipientEmail = @"The action code is invalid. " "This can happen if the code is malformed, expired, or has already been used."; +/** @var kFIRAuthErrorMessageMissingIosBundleID + @brief Message for @c FIRAuthErrorCodeMissingIosbundleID error code. + */ +static NSString *const kFIRAuthErrorMessageMissingIosBundleID = + @"An iOS Bundle ID must be provided if an App Store ID is provided."; + +/** @var kFIRAuthErrorMessageMissingAndroidPackageName + @brief Message for @c FIRAuthErrorCodeMissingAndroidPackageName error code. + */ +static NSString *const kFIRAuthErrorMessageMissingAndroidPackageName = + @"An Android Package Name must be provided if the Android App is required to be installed."; + +/** @var kFIRAuthErrorMessageUnauthorizedDomain + @brief Message for @c FIRAuthErrorCodeUnauthorizedDomain error code. + */ +static NSString *const kFIRAuthErrorMessageUnauthorizedDomain = @"The domain of the continue URL " + "is not whitelisted. Please whitelist the domain in the Firebase console."; + +/** @var kFIRAuthErrorMessageInvalidContinueURI + @brief Message for @c FIRAuthErrorCodeInvalidContinueURI error code. + */ +static NSString *const kFIRAuthErrorMessageInvalidContinueURI = + @"The continue URL provided in the request is invalid."; + /** @var kFIRAuthErrorMessageMissingEmail @brief Message for @c FIRAuthErrorCodeMissingEmail error code. */ @@ -386,6 +410,16 @@ static NSString *FIRAuthErrorDescription(FIRAuthErrorCode code) { return kFIRAuthErrorMessageInvalidMessagePayload; case FIRAuthErrorCodeInvalidRecipientEmail: return kFIRAuthErrorMessageInvalidRecipientEmail; + case FIRAuthErrorCodeMissingIosBundleID: + return kFIRAuthErrorMessageMissingIosBundleID; + case FIRAuthErrorCodeMissingAndroidPackageName: + return kFIRAuthErrorMessageMissingAndroidPackageName; + case FIRAuthErrorCodeUnauthorizedDomain: + return kFIRAuthErrorMessageUnauthorizedDomain; + case FIRAuthErrorCodeInvalidContinueURI: + return kFIRAuthErrorMessageInvalidContinueURI; + case FIRAuthErrorCodeMissingContinueURI: + return kFIRAuthErrorMessageMissingContinueURI; case FIRAuthErrorCodeMissingEmail: return kFIRAuthErrorMessageMissingEmail; case FIRAuthErrorCodeMissingPhoneNumber: @@ -481,6 +515,16 @@ static NSString *const FIRAuthErrorCodeString(FIRAuthErrorCode code) { return @"ERROR_INVALID_SENDER"; case FIRAuthErrorCodeInvalidRecipientEmail: return @"ERROR_INVALID_RECIPIENT_EMAIL"; + case FIRAuthErrorCodeMissingIosBundleID: + return @"ERROR_MISSING_IOS_BUNDLE_ID"; + case FIRAuthErrorCodeMissingAndroidPackageName: + return @"ERROR_MISSING_ANDROID_PKG_NAME"; + case FIRAuthErrorCodeUnauthorizedDomain: + return @"ERROR_UNAUTHORIZED_DOMAIN"; + case FIRAuthErrorCodeInvalidContinueURI: + return @"ERROR_INVALID_CONTINUE_URI"; + case FIRAuthErrorCodeMissingContinueURI: + return @"ERROR_MISSING_CONTINUE_URI"; case FIRAuthErrorCodeMissingEmail: return @"MISSING_EMAIL"; case FIRAuthErrorCodeMissingPhoneNumber: @@ -740,6 +784,26 @@ static NSString *const FIRAuthErrorCodeString(FIRAuthErrorCode code) { return [self errorWithCode:FIRAuthInternalErrorCodeInvalidRecipientEmail message:message]; } ++ (NSError *)missingIosBundleIDErrorWithMessage:(nullable NSString *)message { + return [self errorWithCode:FIRAuthinternalErrorCodeMissingIosBundleID message:message]; +} + ++ (NSError *)missingAndroidPackageNameErrorWithMessage:(nullable NSString *)message { + return [self errorWithCode:FIRAuthInternalErrorCodeMissingAndroidPackageName message:message]; +} + ++ (NSError *)unauthorizedDomainErrorWithMessage:(nullable NSString *)message { + return [self errorWithCode:FIRAuthInternalErrorCodeUnauthorizedDomain message:message]; +} + ++ (NSError *)invalidContinueURIErrorWithMessage:(nullable NSString *)message { + return [self errorWithCode:FIRAuthInternalErrorCodeInvalidContinueURI message:message]; +} + ++ (NSError *)missingContinueURIErrorWithMessage:(nullable NSString *)message { + return[self errorWithCode:FIRAuthInternalErrorCodeMissingContinueURI message:message]; +} + + (NSError *)missingEmail { return [self errorWithCode:FIRAuthInternalErrorCodeMissingEmail]; } diff --git a/Firebase/Auth/Source/FIRAuthInternalErrors.h b/Firebase/Auth/Source/FIRAuthInternalErrors.h index c0fc912..5f4a5c7 100644 --- a/Firebase/Auth/Source/FIRAuthInternalErrors.h +++ b/Firebase/Auth/Source/FIRAuthInternalErrors.h @@ -238,6 +238,34 @@ typedef NS_ENUM(NSInteger, FIRAuthInternalErrorCode) { FIRAuthInternalErrorCodeInvalidRecipientEmail = FIRAuthPublicErrorCodeFlag | FIRAuthErrorCodeInvalidRecipientEmail, + /** Indicates that the iOS bundle ID is missing when a iOS App Store ID is provided. + */ + FIRAuthinternalErrorCodeMissingIosBundleID = + FIRAuthPublicErrorCodeFlag | FIRAuthErrorCodeMissingIosBundleID, + + /** Indicates that the android package name is missing when the @c androidInstallApp flag is set + to true. + */ + FIRAuthInternalErrorCodeMissingAndroidPackageName = + FIRAuthPublicErrorCodeFlag | FIRAuthErrorCodeMissingAndroidPackageName, + + /** Indicates that the domain specified in the continue URL is not whitelisted in the Firebase + console. + */ + FIRAuthInternalErrorCodeUnauthorizedDomain = + FIRAuthPublicErrorCodeFlag | FIRAuthErrorCodeUnauthorizedDomain, + + /** Indicates that the domain specified in the continue URI is not valid. + */ + FIRAuthInternalErrorCodeInvalidContinueURI = + FIRAuthPublicErrorCodeFlag | FIRAuthErrorCodeInvalidContinueURI, + + /** Indicates that a continue URI was not provided in a request to the backend which requires + one. + */ + FIRAuthInternalErrorCodeMissingContinueURI = + FIRAuthPublicErrorCodeFlag | FIRAuthErrorCodeMissingContinueURI, + /** Indicates that an email address was expected but one was not provided. */ FIRAuthInternalErrorCodeMissingEmail = diff --git a/Firebase/Auth/Source/FIRAuth_Internal.h b/Firebase/Auth/Source/FIRAuth_Internal.h index 5d1d13f..245ce57 100644 --- a/Firebase/Auth/Source/FIRAuth_Internal.h +++ b/Firebase/Auth/Source/FIRAuth_Internal.h @@ -18,6 +18,8 @@ #import "FIRAuth.h" +@class FIRAuthRequestConfiguration; + #if TARGET_OS_IOS @class FIRAuthAPNSTokenManager; @class FIRAuthAppCredentialManager; @@ -44,11 +46,11 @@ extern NSString *const FIRAuthStateDidChangeInternalNotificationTokenKey; @interface FIRAuth () -/** @property APIKey - @brief The Google API key. - @remarks Needed for calls to identity toolkit and secure token service. +/** @property requestConfiguration + @brief The configuration object comprising of paramters needed to make a request to Firebase + Auth's backend. */ -@property(nonatomic, copy, readonly) NSString *APIKey; +@property(nonatomic, copy, readonly) FIRAuthRequestConfiguration *requestConfiguration; #if TARGET_OS_IOS /** @property tokenManager diff --git a/Firebase/Auth/Source/FIRSecureTokenService.m b/Firebase/Auth/Source/FIRSecureTokenService.m index 0e5af42..4aa2a50 100644 --- a/Firebase/Auth/Source/FIRSecureTokenService.m +++ b/Firebase/Auth/Source/FIRSecureTokenService.m @@ -20,9 +20,12 @@ #import "FIRAuthKeychain.h" #import "FIRAuthSerialTaskQueue.h" #import "FIRAuthBackend.h" +#import "FIRAuthRequestConfiguration.h" #import "FIRSecureTokenRequest.h" #import "FIRSecureTokenResponse.h" +@class FIRAuthRequestConfiguration; + /** @var kAPIKeyCodingKey @brief The key used to encode the APIKey for NSSecureCoding. */ @@ -57,10 +60,10 @@ static const NSTimeInterval kFiveMinutes = 5 * 60; @end @implementation FIRSecureTokenService { - /** @var _APIKey - @brief A Google API key for making Secure Token Service requests. + /** @var _requestConfiguration + @brief Contains configuration relevant to the request. */ - NSString *_APIKey; + FIRAuthRequestConfiguration *_requestConfiguration; /** @var _taskQueue @brief Used to serialize all requests for access tokens. @@ -86,7 +89,7 @@ static const NSTimeInterval kFiveMinutes = 5 * 60; - (nullable instancetype)initWithAPIKey:(NSString *)APIKey { self = [super init]; if (self) { - _APIKey = [APIKey copy]; + _requestConfiguration = [[FIRAuthRequestConfiguration alloc] initWithAPIKey:APIKey]; _taskQueue = [[FIRAuthSerialTaskQueue alloc] init]; } return self; @@ -160,7 +163,7 @@ static const NSTimeInterval kFiveMinutes = 5 * 60; } - (void)encodeWithCoder:(NSCoder *)aCoder { - [aCoder encodeObject:_APIKey forKey:kAPIKeyCodingKey]; + [aCoder encodeObject:_requestConfiguration.APIKey forKey:kAPIKeyCodingKey]; // Authorization code is not encoded because it is not long-lived. [aCoder encodeObject:_refreshToken forKey:kRefreshTokenKey]; [aCoder encodeObject:_accessToken forKey:kAccessTokenKey]; @@ -184,9 +187,11 @@ static const NSTimeInterval kFiveMinutes = 5 * 60; - (void)requestAccessToken:(FIRFetchAccessTokenCallback)callback { FIRSecureTokenRequest *request; if (_refreshToken.length) { - request = [FIRSecureTokenRequest refreshRequestWithRefreshToken:_refreshToken APIKey:_APIKey]; + request = [FIRSecureTokenRequest refreshRequestWithRefreshToken:_refreshToken + requestConfiguration:_requestConfiguration]; } else { - request = [FIRSecureTokenRequest authCodeRequestWithCode:_authorizationCode APIKey:_APIKey]; + request = [FIRSecureTokenRequest authCodeRequestWithCode:_authorizationCode + requestConfiguration:_requestConfiguration]; } [FIRAuthBackend secureToken:request callback:^(FIRSecureTokenResponse *_Nullable response, diff --git a/Firebase/Auth/Source/FIRUser.m b/Firebase/Auth/Source/FIRUser.m index 82c8bb8..f19c9a1 100644 --- a/Firebase/Auth/Source/FIRUser.m +++ b/Firebase/Auth/Source/FIRUser.m @@ -31,6 +31,7 @@ #import "FIRSecureTokenService.h" #import "FIRUserInfoImpl.h" #import "FIRAuthBackend.h" +#import "FIRAuthRequestConfiguration.h" #import "FIRDeleteAccountRequest.h" #import "FIRDeleteAccountResponse.h" #import "FIRGetAccountInfoRequest.h" @@ -215,7 +216,7 @@ static void callInMainThreadWithAuthDataResultAndError( */ NSDictionary<NSString *, FIRUserInfoImpl *> *_providerData; - /** @var _APIKey + /** @var _APIKey @brief The application's API Key. */ NSString *_APIKey; @@ -262,7 +263,8 @@ static void callInMainThreadWithAuthDataResultAndError( return; } FIRGetAccountInfoRequest *getAccountInfoRequest = - [[FIRGetAccountInfoRequest alloc] initWithAPIKey:APIKey accessToken:accessToken]; + [[FIRGetAccountInfoRequest alloc] initWithAccessToken:accessToken + requestConfiguration:[FIRAuth auth].requestConfiguration]; [FIRAuthBackend getAccountInfo:getAccountInfoRequest callback:^(FIRGetAccountInfoResponse *_Nullable response, NSError *_Nullable error) { @@ -387,7 +389,8 @@ static void callInMainThreadWithAuthDataResultAndError( return; } FIRGetAccountInfoRequest *getAccountInfoRequest = - [[FIRGetAccountInfoRequest alloc] initWithAPIKey:_APIKey accessToken:accessToken]; + [[FIRGetAccountInfoRequest alloc] initWithAccessToken:accessToken + requestConfiguration:_auth.requestConfiguration]; [FIRAuthBackend getAccountInfo:getAccountInfoRequest callback:^(FIRGetAccountInfoResponse *_Nullable response, NSError *_Nullable error) { @@ -452,9 +455,11 @@ static void callInMainThreadWithAuthDataResultAndError( callback(error); return; } + FIRAuthRequestConfiguration *configuration = + _auth.requestConfiguration; // Mutate setAccountInfoRequest in block: FIRSetAccountInfoRequest *setAccountInfoRequest = - [[FIRSetAccountInfoRequest alloc] initWithAPIKey:_APIKey]; + [[FIRSetAccountInfoRequest alloc] initWithRequestConfiguration:configuration]; setAccountInfoRequest.accessToken = accessToken; changeBlock(user, setAccountInfoRequest); // Execute request: @@ -571,8 +576,10 @@ static void callInMainThreadWithAuthDataResultAndError( callback(error); return; } + FIRAuthRequestConfiguration *requestConfiguration = _auth.requestConfiguration; FIRGetAccountInfoRequest *getAccountInfoRequest = - [[FIRGetAccountInfoRequest alloc] initWithAPIKey:_APIKey accessToken:accessToken]; + [[FIRGetAccountInfoRequest alloc] initWithAccessToken:accessToken + requestConfiguration:requestConfiguration]; [FIRAuthBackend getAccountInfo:getAccountInfoRequest callback:^(FIRGetAccountInfoResponse *_Nullable response, NSError *_Nullable error) { @@ -638,7 +645,7 @@ static void callInMainThreadWithAuthDataResultAndError( FIRVerifyPhoneNumberRequest *request = [[FIRVerifyPhoneNumberRequest alloc] initWithVerificationID:phoneAuthCredential.verificationID verificationCode:phoneAuthCredential.verificationCode - APIKey:_APIKey]; + requestConfiguration:_auth.requestConfiguration]; request.accessToken = accessToken; [FIRAuthBackend verifyPhoneNumber:request callback:^(FIRVerifyPhoneNumberResponse *_Nullable response, @@ -882,8 +889,10 @@ static void callInMainThreadWithAuthDataResultAndError( completeWithError(nil, error); return; } + FIRAuthRequestConfiguration *requestConfiguration = _auth.requestConfiguration; FIRVerifyAssertionRequest *request = - [[FIRVerifyAssertionRequest alloc] initWithAPIKey:_APIKey providerID:credential.provider]; + [[FIRVerifyAssertionRequest alloc] initWithProviderID:credential.provider + requestConfiguration:requestConfiguration]; [credential prepareVerifyAssertionRequest:request]; request.accessToken = accessToken; [FIRAuthBackend verifyAssertion:request @@ -909,7 +918,8 @@ static void callInMainThreadWithAuthDataResultAndError( return; } FIRGetAccountInfoRequest *getAccountInfoRequest = - [[FIRGetAccountInfoRequest alloc] initWithAPIKey:_APIKey accessToken:accessToken]; + [[FIRGetAccountInfoRequest alloc] initWithAccessToken:accessToken + requestConfiguration:requestConfiguration]; [FIRAuthBackend getAccountInfo:getAccountInfoRequest callback:^(FIRGetAccountInfoResponse *_Nullable response, NSError *_Nullable error) { @@ -945,8 +955,9 @@ static void callInMainThreadWithAuthDataResultAndError( completeAndCallbackWithError(error); return; } + FIRAuthRequestConfiguration *requestConfiguration = _auth.requestConfiguration; FIRSetAccountInfoRequest *setAccountInfoRequest = - [[FIRSetAccountInfoRequest alloc] initWithAPIKey:_APIKey]; + [[FIRSetAccountInfoRequest alloc] initWithRequestConfiguration:requestConfiguration]; setAccountInfoRequest.accessToken = accessToken; BOOL isEmailPasswordProvider = [provider isEqualToString:FIREmailAuthProviderID]; if (isEmailPasswordProvider) { @@ -1008,6 +1019,27 @@ static void callInMainThreadWithAuthDataResultAndError( } - (void)sendEmailVerificationWithCompletion:(nullable FIRSendEmailVerificationCallback)completion { + [self sendEmailVerificationWithNullableActionCodeSettings:nil completion:completion]; +} + +- (void)sendEmailVerificationWithActionCodeSettings:(FIRActionCodeSettings *)actionCodeSettings + completion:(nullable FIRSendEmailVerificationCallback) + completion { + [self sendEmailVerificationWithNullableActionCodeSettings:actionCodeSettings + completion:completion]; +} + +/** @fn sendEmailVerificationWithNullableActionCodeSettings:completion: + @brief Initiates email verification for the user. + + @param actionCodeSettings Optionally, a @c FIRActionCodeSettings object containing settings + related to the handling action codes. + */ +- (void)sendEmailVerificationWithNullableActionCodeSettings:(nullable FIRActionCodeSettings *) + actionCodeSettings + completion: + (nullable FIRSendEmailVerificationCallback) + completion { dispatch_async(FIRAuthGlobalWorkQueue(), ^{ [self internalGetTokenWithCallback:^(NSString *_Nullable accessToken, NSError *_Nullable error) { @@ -1015,9 +1047,11 @@ static void callInMainThreadWithAuthDataResultAndError( callInMainThreadWithError(completion, error); return; } + FIRAuthRequestConfiguration *configuration = _auth.requestConfiguration; FIRGetOOBConfirmationCodeRequest *request = [FIRGetOOBConfirmationCodeRequest verifyEmailRequestWithAccessToken:accessToken - APIKey:_APIKey]; + actionCodeSettings:actionCodeSettings + requestConfiguration:configuration]; [FIRAuthBackend getOOBConfirmationCode:request callback:^(FIRGetOOBConfirmationCodeResponse *_Nullable response, @@ -1037,15 +1071,15 @@ static void callInMainThreadWithAuthDataResultAndError( return; } FIRDeleteAccountRequest *deleteUserRequest = - [[FIRDeleteAccountRequest alloc] initWithAPIKey:_APIKey - localID:_userID - accessToken:accessToken]; + [[FIRDeleteAccountRequest alloc] initWitLocalID:_userID + accessToken:accessToken + requestConfiguration:_auth.requestConfiguration]; [FIRAuthBackend deleteAccount:deleteUserRequest callback:^(NSError *_Nullable error) { if (error) { callInMainThreadWithError(completion, error); return; } - if (![[FIRAuth auth] signOutByForceWithUserID:_userID error:&error]) { + if (![_auth signOutByForceWithUserID:_userID error:&error]) { callInMainThreadWithError(completion, error); return; } diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/ar.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/ar.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..3921782 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/ar.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "ar"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/bg.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/bg.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..b9b69b8 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/bg.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "bg"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/bn.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/bn.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..7bb381d --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/bn.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "bn"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/ca.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/ca.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..0b4710c --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/ca.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "ca"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/cs.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/cs.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..132370c --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/cs.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "cs"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/da.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/da.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..442d3e9 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/da.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "da"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/de.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/de.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..d5d1860 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/de.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "de"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/dl.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/dl.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..c31ac37 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/dl.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "dl"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/el.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/el.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..83a7902 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/el.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "el"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/en-GB.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/en-GB.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..d613388 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/en-GB.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "en-GB"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/en.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/en.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..f5e9d16 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/en.lproj/FirebaseLocale.strings @@ -0,0 +1,2 @@ +"FIREBASE_LOCALE_STRING" = "en"; + diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/es-419.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/es-419.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..5c145e9 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/es-419.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "es-419"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/es.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/es.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..86b8321 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/es.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "es"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/fa.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/fa.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..9ef882f --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/fa.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "fa"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/fi.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/fi.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..2865804 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/fi.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "fi"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/fil.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/fil.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..0d129d4 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/fil.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "fil"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/fr.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/fr.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..8c9a083 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/fr.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "fr"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/gu.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/gu.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..37785db --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/gu.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "gu"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/hi.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/hi.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..0df898e --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/hi.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "hi"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/hr.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/hr.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..dedc776 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/hr.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "hr"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/hu.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/hu.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..7cd8314 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/hu.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "hu"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/id.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/id.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..1114a7c --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/id.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "id"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/it.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/it.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..f10172c --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/it.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "it"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/iw.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/iw.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..e321c03 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/iw.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "iw"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/ja.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/ja.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..a9e41d6 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/ja.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "ja"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/kn.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/kn.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..ef998cb --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/kn.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "kn"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/ko.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/ko.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..e28f0b7 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/ko.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "ko"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/lt.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/lt.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..874ebef --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/lt.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "lt"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/lv.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/lv.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..e5cb109 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/lv.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "lv"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/ml.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/ml.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..3630531 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/ml.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "ml"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/mr.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/mr.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..8f563d7 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/mr.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "mr"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/ms.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/ms.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..883486f --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/ms.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "ms"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/nl.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/nl.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..cea8c6e --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/nl.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "nl"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/no.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/no.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..2f28296 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/no.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "no"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/pl.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/pl.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..42c5ced --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/pl.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "pl"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/pt-BR.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/pt-BR.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..c79c6ef --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/pt-BR.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "pt-BR"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/pt-PT.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/pt-PT.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..e9317d6 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/pt-PT.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "pt-PT"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/pt.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/pt.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..a2585d3 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/pt.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "pt"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/ro.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/ro.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..0e79c52 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/ro.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "ro"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/ru.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/ru.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..76cb5f4 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/ru.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "ru"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/sk.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/sk.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..c94c719 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/sk.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "sk"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/sl.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/sl.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..64a3a2c --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/sl.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "sl"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/sr.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/sr.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..49bff6d --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/sr.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "sr"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/sv.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/sv.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..e0eb3d5 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/sv.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "sv"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/ta.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/ta.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..0f16c0d --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/ta.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "ta"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/th.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/th.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..bf5323d --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/th.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "th"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/tr.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/tr.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..558eba3 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/tr.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "tr"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/uk.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/uk.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..5950a21 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/uk.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "uk"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/ur.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/ur.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..5e22334 --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/ur.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "ur"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/vi.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/vi.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..6af2e0d --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/vi.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "vi"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/zh-CN.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/zh-CN.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..06c8d2d --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/zh-CN.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "zh-CN"; diff --git a/Firebase/Auth/Source/FirebaseAuth.bundle/zh-TW.lproj/FirebaseLocale.strings b/Firebase/Auth/Source/FirebaseAuth.bundle/zh-TW.lproj/FirebaseLocale.strings new file mode 100644 index 0000000..9e660ad --- /dev/null +++ b/Firebase/Auth/Source/FirebaseAuth.bundle/zh-TW.lproj/FirebaseLocale.strings @@ -0,0 +1 @@ +"FIREBASE_LOCALE_STRING" = "zh-TW"; diff --git a/Firebase/Auth/Source/Public/FIRActionCodeSettings.h b/Firebase/Auth/Source/Public/FIRActionCodeSettings.h new file mode 100644 index 0000000..fef0175 --- /dev/null +++ b/Firebase/Auth/Source/Public/FIRActionCodeSettings.h @@ -0,0 +1,83 @@ +/* + * Copyright 2017 Google + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + #import <Foundation/Foundation.h> + + NS_ASSUME_NONNULL_BEGIN + + /** @class FIRActionCodeSettings + @brief Used to set and retrieve settings related to the handling action codes. + */ + @interface FIRActionCodeSettings : NSObject + + /** @property URL + @brief This URL represents the state/Continue URL in the form of a universal link. + @remarks This URL can should be contructed as a universal link that would either directly open + the app where the action code would be handled or continue to the app after the action code + handled by Firebase. + */ + @property(nonatomic, copy, nullable) NSURL *URL; + + /** @property handleCodeInApp + @brief Indicates whether or not the action code link will open the app directly or after being + redirected from a Firebase owned web widget. + */ + @property(assign, nonatomic) BOOL handleCodeInApp; + + /** @property iOSBundleID + @brief The iOS bundle ID, if available. + */ + @property(copy, nonatomic, readonly, nullable) NSString *iOSBundleID; + + /** @property androidPackageName + @brief The Android package name, if available. + */ + @property(nonatomic, copy, readonly, nullable) NSString *androidPackageName; + + /** @property androidMinimumVersion + @brief The minimum Android version supported, if available. + */ + @property(nonatomic, copy, readonly, nullable) NSString *androidMinimumVersion; + + /** @property androidInstallIfNotAvailable + @brief Indicates whether the Android app should be installed or not on a device where it is not + available. + */ + @property(nonatomic, assign, readonly) BOOL androidInstallIfNotAvailable; + + /** @fn setIOSBundleID + @brief Sets the iOS bundle Id. + @param iOSBundleID The iOS bundle ID. + */ + - (void)setIOSBundleID:(NSString *)iOSBundleID; + + /** @fn setAndroidPackageName:installIfNotAvailable:minimumVersion: + @brief Sets the Android package name, the flag to indicate whether or not to install the app and + the minimum Android version supported. + @param androidPackageName The Android package name. + @param installIfNotAvailable Indicates whether or not the app should be installed if not + available. + @param minimumVersion The minimum version of Android supported. + @remarks If installIfNotAvailable is set to YES 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. + */ + - (void)setAndroidPackageName:(NSString *)androidPackageName + installIfNotAvailable:(BOOL)installIfNotAvailable + minimumVersion:(nullable NSString *)minimumVersion; + + @end + + NS_ASSUME_NONNULL_END diff --git a/Firebase/Auth/Source/Public/FIRAuth.h b/Firebase/Auth/Source/Public/FIRAuth.h index 356c8dd..e120eb2 100644 --- a/Firebase/Auth/Source/Public/FIRAuth.h +++ b/Firebase/Auth/Source/Public/FIRAuth.h @@ -23,6 +23,7 @@ #import "FIRAuthAPNSTokenType.h" #endif +@class FIRActionCodeSettings; @class FIRApp; @class FIRAuth; @class FIRAuthCredential; @@ -252,6 +253,14 @@ FIR_SWIFT_NAME(Auth) */ @property(nonatomic, strong, readonly, nullable) FIRUser *currentUser; +/** @proprty languageCode + @brief The current user language code. This property can be set to the app's current language by + calling @c useAppLanguage. + + @remarks The string used to set this property must be a language code that follows BCP 47. + */ +@property (nonatomic, copy, nullable) NSString *languageCode; + #if TARGET_OS_IOS /** @property APNSToken @brief The APNs token used for phone number authentication. The type of the token (production @@ -531,6 +540,44 @@ FIR_SWIFT_NAME(Auth) - (void)sendPasswordResetWithEmail:(NSString *)email completion:(nullable FIRSendPasswordResetCallback)completion; +/** @fn sendPasswordResetWithEmail:actionCodeSetting:completion: + @brief Initiates a password reset for the given email address and @FIRActionCodeSettings object. + + @param email The email address of the user. + @param actionCodeSettings An @c FIRActionCodeSettings object containing settings related to the + handling action codes. + @param completion Optionally; a block which is invoked when the request finishes. Invoked + asynchronously on the main thread in the future. + + @remarks Possible error codes: + <ul> + <li>@c FIRAuthErrorCodeInvalidRecipientEmail - Indicates an invalid recipient email was + sent in the request. + </li> + <li>@c FIRAuthErrorCodeInvalidSender - Indicates an invalid sender email is set in + the console for this action. + </li> + <li>@c FIRAuthErrorCodeInvalidMessagePayload - Indicates an invalid email template for + sending update email. + </li> + <li>@c FIRAuthErrorCodeMissingIosBundleID - Indicates that the iOS bundle ID is missing when + a iOS App Store ID is provided. + </li> + <li>@c FIRAuthErrorCodeMissingAndroidPackageName - Indicates that the android package name + is missing when the @c androidInstallApp flag is set to true. + </li> + <li>@c FIRAuthErrorCodeUnauthorizedDomain - Indicates that the domain specified in the + continue URL is not whitelisted in the Firebase console. + </li> + <li>@c FIRAuthErrorCodeInvalidContinueURI - Indicates that the domain specified in the + continue URI is not valid. + </li> + </ul> + */ + - (void)sendPasswordResetWithEmail:(NSString *)email + actionCodeSettings:(FIRActionCodeSettings *)actionCodeSettings + completion:(nullable FIRSendPasswordResetCallback)completion; + /** @fn signOut: @brief Signs out the current user. @@ -606,6 +653,11 @@ FIR_SWIFT_NAME(Auth) */ - (void)removeIDTokenDidChangeListener:(FIRIDTokenDidChangeListenerHandle)listenerHandle; +/** @fn useAppLanguage + @brief Sets @c languageCode to the app's current language. + */ +- (void)useAppLanguage; + #if TARGET_OS_IOS /** @fn setAPNSToken:type: @brief Sets the APNs token along with its type. diff --git a/Firebase/Auth/Source/Public/FIRAuthErrors.h b/Firebase/Auth/Source/Public/FIRAuthErrors.h index 0b161f7..2859161 100644 --- a/Firebase/Auth/Source/Public/FIRAuthErrors.h +++ b/Firebase/Auth/Source/Public/FIRAuthErrors.h @@ -188,8 +188,30 @@ typedef NS_ENUM(NSInteger, FIRAuthErrorCode) { */ FIRAuthErrorCodeMissingEmail = 17034, - // The enum values between 17034 and 17041 are reserved and should NOT be used for new error - // codes. + // The enum values 17035 is reserved and should NOT be used for new error codes. + + /** Indicates that the iOS bundle ID is missing when a iOS App Store ID is provided. + */ + FIRAuthErrorCodeMissingIosBundleID = 17036, + + /** Indicates that the android package name is missing when the @c androidInstallApp flag is set + to true. + */ + FIRAuthErrorCodeMissingAndroidPackageName = 17037, + + /** Indicates that the domain specified in the continue URL is not whitelisted in the Firebase + console. + */ + FIRAuthErrorCodeUnauthorizedDomain = 17038, + + /** Indicates that the domain specified in the continue URI is not valid. + */ + FIRAuthErrorCodeInvalidContinueURI = 17039, + + /** Indicates that a continue URI was not provided in a request to the backend which requires + one. + */ + FIRAuthErrorCodeMissingContinueURI = 17040, /** Indicates that a phone number was not provided in a call to @c verifyPhoneNumber:completion:. diff --git a/Firebase/Auth/Source/Public/FIRUser.h b/Firebase/Auth/Source/Public/FIRUser.h index 9e3ac77..8d0e8f6 100644 --- a/Firebase/Auth/Source/Public/FIRUser.h +++ b/Firebase/Auth/Source/Public/FIRUser.h @@ -401,6 +401,42 @@ FIR_SWIFT_NAME(User) */ - (void)sendEmailVerificationWithCompletion:(nullable FIRSendEmailVerificationCallback)completion; +/** @fn sendEmailVerificationWithActionCodeSettings:completion: + @brief Initiates email verification for the user. + + @param actionCodeSettings An @c FIRActionCodeSettings object containing settings related to the + handling action codes. + + @remarks Possible error codes: + <ul> + <li>@c FIRAuthErrorCodeInvalidRecipientEmail - Indicates an invalid recipient email was + sent in the request. + </li> + <li>@c FIRAuthErrorCodeInvalidSender - Indicates an invalid sender email is set in + the console for this action. + </li> + <li>@c FIRAuthErrorCodeInvalidMessagePayload - Indicates an invalid email template for + sending update email. + </li> + <li>@c FIRAuthErrorCodeUserNotFound - Indicates the user account was not found.</li> + <li>@c FIRAuthErrorCodeMissingIosBundleID - Indicates that the iOS bundle ID is missing when + a iOS App Store ID is provided. + </li> + <li>@c FIRAuthErrorCodeMissingAndroidPackageName - Indicates that the android package name + is missing when the @c androidInstallApp flag is set to true. + </li> + <li>@c FIRAuthErrorCodeUnauthorizedDomain - Indicates that the domain specified in the + continue URL is not whitelisted in the Firebase console. + </li> + <li>@c FIRAuthErrorCodeInvalidContinueURI - Indicates that the domain specified in the + continue URI is not valid. + </li> + </ul> + */ +- (void)sendEmailVerificationWithActionCodeSettings:(FIRActionCodeSettings *)actionCodeSettings + completion:(nullable FIRSendEmailVerificationCallback) + completion; + /** @fn deleteWithCompletion: @brief Deletes the user account (also signs out the user, if this was the current user). diff --git a/Firebase/Auth/Source/Public/FirebaseAuth.h b/Firebase/Auth/Source/Public/FirebaseAuth.h index ef4aca6..126645e 100644 --- a/Firebase/Auth/Source/Public/FirebaseAuth.h +++ b/Firebase/Auth/Source/Public/FirebaseAuth.h @@ -22,6 +22,7 @@ #import "FIRGoogleAuthProvider.h" #import "FIROAuthProvider.h" #import "FIRTwitterAuthProvider.h" +#import "FIRActionCodeSettings.h" #import "FIRAdditionalUserInfo.h" #import "FIRAuth.h" #import "FIRAuthCredential.h" diff --git a/Firebase/Auth/Source/RPCs/FIRAuthBackend.h b/Firebase/Auth/Source/RPCs/FIRAuthBackend.h index 521cf16..b560644 100644 --- a/Firebase/Auth/Source/RPCs/FIRAuthBackend.h +++ b/Firebase/Auth/Source/RPCs/FIRAuthBackend.h @@ -16,6 +16,7 @@ #import <Foundation/Foundation.h> +@class FIRAuthRequestConfiguration; @class FIRCreateAuthURIRequest; @class FIRCreateAuthURIResponse; @class FIRGetAccountInfoRequest; @@ -348,18 +349,20 @@ typedef void (^FIRVerifyClientResponseCallback) */ @protocol FIRAuthBackendRPCIssuer <NSObject> -/** @fn asyncPostToURL:body:contentType:completionHandler: - @brief Asynchronously sends a POST request. - @param URL URL of the request. +/** @fn asyncPostToURLWithRequestConfiguration:URL:body:contentType:completionHandler: + @brief Asynchronously seXnds a POST request. + @param requestConfiguration The request to be made. + @param URL The request URL. @param body Request body. @param contentType Content type of the body. @param handler provided that handles POST response. Invoked asynchronously on the auth global work queue in the future. */ -- (void)asyncPostToURL:(NSURL *)URL - body:(NSData *)body - contentType:(NSString *)contentType - completionHandler:(FIRAuthBackendRPCIssuerCompletionHandler)handler; +- (void)asyncPostToURLWithRequestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration + URL:(NSURL *)URL + body:(NSData *)body + contentType:(NSString *)contentType + completionHandler:(FIRAuthBackendRPCIssuerCompletionHandler)handler; @end diff --git a/Firebase/Auth/Source/RPCs/FIRAuthBackend.m b/Firebase/Auth/Source/RPCs/FIRAuthBackend.m index b2b5a34..7e31993 100644 --- a/Firebase/Auth/Source/RPCs/FIRAuthBackend.m +++ b/Firebase/Auth/Source/RPCs/FIRAuthBackend.m @@ -69,6 +69,11 @@ static NSString *const kClientVersionHeader = @"X-Client-Version"; */ static NSString *const kIosBundleIdentifierHeader = @"X-Ios-Bundle-Identifier"; +/** @var kFirebaseLocalHeader + @brief HTTP header name for the firebase locale. + */ +static NSString *const kFirebaseLocalHeader = @"X-Firebase-Locale"; + /** @var kJSONContentType @brief The value of the HTTP content-type header for JSON payloads. */ @@ -246,6 +251,36 @@ static NSString *const kInvalidMessagePayloadErrorMessage = @"INVALID_MESSAGE_PA */ static NSString *const kInvalidRecipientEmailErrorMessage = @"INVALID_RECIPIENT_EMAIL"; +/** @var kMissingIosBundleIDErrorMessage + @brief This is the error message the server will respond with if iOS bundle ID is missing but + the iOS App store ID is provided. + */ +static NSString *const kMissingIosBundleIDErrorMessage = @"MISSING_IOS_BUNDLE_ID"; + +/** @var kMissingAndroidPackageNameErrorMessage + @brief This is the error message the server will respond with if Android Package Name is missing + but the flag indicating the app should be installed is set to true. + */ +static NSString *const kMissingAndroidPackageNameErrorMessage = @"MISSING_ANDROID_PACKAGE_NAME"; + +/** @var kUnauthorizedDomainErrorMessage + @brief This is the error message the server will respond with if the domain of the continue URL + specified is not whitelisted in the firebase console. + */ +static NSString *const kUnauthorizedDomainErrorMessage = @"ERROR_UNAUTHORIZED_DOMAIN"; + +/** @var kInvalidContinueURIErrorMessage + @brief This is the error message the server will respond with if the continue URL provided in + the request is invalid. + */ +static NSString *const kInvalidContinueURIErrorMessage = @"INVALID_CONTINUE_URI"; + +/** @var kMissingContinueURIErrorMessage + @brief This is the error message the server will respond with if there was no continue URI + present in a request that required one. + */ +static NSString *const kMissingContinueURIErrorMessage = @"MISSING_CONTINUE_URI"; + /** @var kInvalidPhoneNumberErrorMessage @brief This is the error message the server will respond with if an incorrectly formatted phone number is provided. @@ -427,10 +462,12 @@ static id<FIRAuthBackendImplementation> gBackendImplementation; return self; } -- (void)asyncPostToURL:(NSURL *)URL - body:(NSData *)body - contentType:(NSString *)contentType - completionHandler:(void (^)(NSData *_Nullable, NSError *_Nullable))handler { +- (void)asyncPostToURLWithRequestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration + URL:(NSURL *)URL + body:(NSData *)body + contentType:(NSString *)contentType + completionHandler:(void (^)(NSData *_Nullable, + NSError *_Nullable))handler { NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL]; [request setValue:contentType forHTTPHeaderField:@"Content-Type"]; NSString *clientVersion = @@ -444,7 +481,10 @@ static id<FIRAuthBackendImplementation> gBackendImplementation; NSString *acceptLanguage = preferredLocalizations.firstObject; [request setValue:acceptLanguage forHTTPHeaderField:@"Accept-Language"]; } - + NSString *languageCode = requestConfiguration.languageCode; + if (languageCode.length) { + [request setValue:languageCode forHTTPHeaderField:kFirebaseLocalHeader]; + } GTMSessionFetcher* fetcher = [_fetcherService fetcherWithRequest:request]; fetcher.bodyData = body; [fetcher beginFetchWithCompletionHandler:handler]; @@ -684,10 +724,11 @@ static id<FIRAuthBackendImplementation> gBackendImplementation; return; } - [_RPCIssuer asyncPostToURL:[request requestURL] - body:bodyData - contentType:kJSONContentType - completionHandler:^(NSData *data, NSError *error) { + [_RPCIssuer asyncPostToURLWithRequestConfiguration:[request requestConfiguration] + URL:[request requestURL] + body:bodyData + contentType:kJSONContentType + completionHandler:^(NSData *data, NSError *error) { // If there is an error with no body data at all, then this must be a network error. if (error && !data) { callback([FIRAuthErrorUtils networkErrorWithUnderlyingError:error]); @@ -901,6 +942,26 @@ static id<FIRAuthBackendImplementation> gBackendImplementation; return [FIRAuthErrorUtils invalidRecipientEmailErrorWithMessage:serverDetailErrorMessage]; } + if ([shortErrorMessage isEqualToString:kMissingIosBundleIDErrorMessage]) { + return [FIRAuthErrorUtils missingIosBundleIDErrorWithMessage:serverDetailErrorMessage]; + } + + if ([shortErrorMessage isEqualToString:kMissingAndroidPackageNameErrorMessage]) { + return [FIRAuthErrorUtils missingAndroidPackageNameErrorWithMessage:serverDetailErrorMessage]; + } + + if ([shortErrorMessage isEqualToString:kUnauthorizedDomainErrorMessage]) { + return [FIRAuthErrorUtils unauthorizedDomainErrorWithMessage:serverDetailErrorMessage]; + } + + if ([shortErrorMessage isEqualToString:kInvalidContinueURIErrorMessage]) { + return [FIRAuthErrorUtils invalidContinueURIErrorWithMessage:serverDetailErrorMessage]; + } + + if ([shortErrorMessage isEqualToString:kMissingContinueURIErrorMessage]) { + return [FIRAuthErrorUtils missingContinueURIErrorWithMessage:serverDetailErrorMessage]; + } + if ([shortErrorMessage isEqualToString:kInvalidPhoneNumberErrorMessage]) { return [FIRAuthErrorUtils invalidPhoneNumberErrorWithMessage:serverDetailErrorMessage]; } diff --git a/Firebase/Auth/Source/RPCs/FIRAuthRPCRequest.h b/Firebase/Auth/Source/RPCs/FIRAuthRPCRequest.h index ddad3cb..cde0bd8 100644 --- a/Firebase/Auth/Source/RPCs/FIRAuthRPCRequest.h +++ b/Firebase/Auth/Source/RPCs/FIRAuthRPCRequest.h @@ -16,6 +16,8 @@ #import <Foundation/Foundation.h> +@class FIRAuthRequestConfiguration; + NS_ASSUME_NONNULL_BEGIN /** @protocol FIRAuthRPCRequest @@ -35,6 +37,14 @@ NS_ASSUME_NONNULL_BEGIN */ - (nullable id)unencodedHTTPRequestBodyWithError:(NSError *_Nullable *_Nullable)error; +@optional + +/** @fn requestConfiguration + @brief Obtains the request configurations if available. + @return Returns the request configurations. + */ +- (FIRAuthRequestConfiguration *)requestConfiguration; + @end NS_ASSUME_NONNULL_END diff --git a/Firebase/Auth/Source/RPCs/FIRAuthRequestConfiguration.h b/Firebase/Auth/Source/RPCs/FIRAuthRequestConfiguration.h new file mode 100644 index 0000000..1aec6f6 --- /dev/null +++ b/Firebase/Auth/Source/RPCs/FIRAuthRequestConfiguration.h @@ -0,0 +1,47 @@ +/* + * Copyright 2017 Google + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import <Foundation/Foundation.h> + +#import "FIRAuthRPCRequest.h" + +NS_ASSUME_NONNULL_BEGIN + +/** @class FIRAuthRequestConfiguration + @brief Defines configurations to be added to a request to Firebase Auth's backend. + */ +@interface FIRAuthRequestConfiguration : NSObject + +/** @property APIKey + @brief The Firebase Auth API key used in the request. + */ +@property(nonatomic, copy, readonly) NSString *APIKey; + +/** @property LanguageCode + @brief The language code used in the request. + */ +@property(nonatomic, copy, nullable) NSString *languageCode; + +- (nullable instancetype)init NS_UNAVAILABLE; + +/** @fn initWithRequestClass:APIKey:authLanguage: + @brief Designated initializer. + @param APIKey The API key to be used in the request. + */ +- (nullable instancetype)initWithAPIKey:(NSString *)APIKey NS_DESIGNATED_INITIALIZER; +@end + +NS_ASSUME_NONNULL_END diff --git a/Firebase/Auth/Source/RPCs/FIRAuthRequestConfiguration.m b/Firebase/Auth/Source/RPCs/FIRAuthRequestConfiguration.m new file mode 100644 index 0000000..a4ee5dd --- /dev/null +++ b/Firebase/Auth/Source/RPCs/FIRAuthRequestConfiguration.m @@ -0,0 +1,34 @@ +/* + * Copyright 2017 Google + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "FIRAuthRequestConfiguration.h" +#import "FIRAuthExceptionUtils.h" + +NS_ASSUME_NONNULL_BEGIN + +@implementation FIRAuthRequestConfiguration + +- (nullable instancetype)initWithAPIKey:(NSString *)APIKey { + self = [super init]; + if (self) { + _APIKey = [APIKey copy]; + } + return self; +} + +@end + +NS_ASSUME_NONNULL_END diff --git a/Firebase/Auth/Source/RPCs/FIRCreateAuthURIRequest.h b/Firebase/Auth/Source/RPCs/FIRCreateAuthURIRequest.h index bb28826..a4fb6f5 100644 --- a/Firebase/Auth/Source/RPCs/FIRCreateAuthURIRequest.h +++ b/Firebase/Auth/Source/RPCs/FIRCreateAuthURIRequest.h @@ -65,21 +65,23 @@ NS_ASSUME_NONNULL_BEGIN */ @property(nonatomic, copy, nullable) NSString *appID; -/** @fn initWithEndpoint:APIKey: - @brief Please use initWithIdentifier:continueURI:APIKey: +/** @fn initWithEndpoint:requestConfiguration:requestConfiguration. + @brief Please use initWithIdentifier:continueURI:requestConfiguration: instead. */ - (nullable instancetype)initWithEndpoint:(NSString *)endpoint - APIKey:(NSString *)APIKey NS_UNAVAILABLE; + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration + NS_UNAVAILABLE; -/** @fn initWithIdentifier:continueURI:APIKey: +/** @fn initWithIdentifier:continueURI:requestConfiguration: @brief Designated initializer. @param identifier The email or federated ID of the user. @param continueURI The URI to which the IDP redirects the user after the federated login flow. - @param APIKey The client's API Key. + @param requestConfiguration An object containing configurations to be added to the request. */ - (nullable instancetype)initWithIdentifier:(NSString *)identifier continueURI:(NSString *)continueURI - APIKey:(NSString *)APIKey NS_DESIGNATED_INITIALIZER; + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration + NS_DESIGNATED_INITIALIZER; @end diff --git a/Firebase/Auth/Source/RPCs/FIRCreateAuthURIRequest.m b/Firebase/Auth/Source/RPCs/FIRCreateAuthURIRequest.m index 6d2b9e9..dae46fb 100644 --- a/Firebase/Auth/Source/RPCs/FIRCreateAuthURIRequest.m +++ b/Firebase/Auth/Source/RPCs/FIRCreateAuthURIRequest.m @@ -60,8 +60,8 @@ static NSString *const kAppIDKey = @"appId"; - (nullable instancetype)initWithIdentifier:(NSString *)identifier continueURI:(NSString *)continueURI - APIKey:(NSString *)APIKey { - self = [super initWithEndpoint:kCreateAuthURIEndpoint APIKey:APIKey]; + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration { + self = [super initWithEndpoint:kCreateAuthURIEndpoint requestConfiguration:requestConfiguration]; if (self) { _identifier = [identifier copy]; _continueURI = [continueURI copy]; diff --git a/Firebase/Auth/Source/RPCs/FIRDeleteAccountRequest.h b/Firebase/Auth/Source/RPCs/FIRDeleteAccountRequest.h index 1751e54..89a7d26 100644 --- a/Firebase/Auth/Source/RPCs/FIRDeleteAccountRequest.h +++ b/Firebase/Auth/Source/RPCs/FIRDeleteAccountRequest.h @@ -27,21 +27,23 @@ NS_ASSUME_NONNULL_BEGIN */ @interface FIRDeleteAccountRequest : FIRIdentityToolkitRequest<FIRAuthRPCRequest> -/** @fn initWithEndpoint:APIKey: - @brief Please use initWithAPIKey: +/** @fn initWithEndpoint:requestConfiguration:requestConfiguration. + @brief Please use initWitLocalID:accessToken:requestConfiguration instead. */ - (nullable instancetype)initWithEndpoint:(NSString *)endpoint - APIKey:(NSString *)APIKey NS_UNAVAILABLE; + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration + NS_UNAVAILABLE; -/** @fn initWithAPIKey: +/** @fn initWitLocalID:accessToken:requestConfiguration. @brief Designated initializer. - @param APIKey The client's API Key. @param localID The local ID. @param accessToken The access token. + @param requestConfiguration An object containing configurations to be added to the request. */ -- (nullable instancetype)initWithAPIKey:(NSString *)APIKey - localID:(NSString *)localID - accessToken:(NSString *)accessToken NS_DESIGNATED_INITIALIZER; +- (nullable instancetype)initWitLocalID:(NSString *)localID + accessToken:(NSString *)accessToken + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration + NS_DESIGNATED_INITIALIZER; @end diff --git a/Firebase/Auth/Source/RPCs/FIRDeleteAccountRequest.m b/Firebase/Auth/Source/RPCs/FIRDeleteAccountRequest.m index 9105ba0..2222210 100644 --- a/Firebase/Auth/Source/RPCs/FIRDeleteAccountRequest.m +++ b/Firebase/Auth/Source/RPCs/FIRDeleteAccountRequest.m @@ -44,10 +44,10 @@ static NSString *const kLocalIDKey = @"localId"; NSString *_localID; } -- (nullable instancetype)initWithAPIKey:(NSString *)APIKey - localID:(nonnull NSString *)localID - accessToken:(nonnull NSString *)accessToken { - self = [super initWithEndpoint:kDeleteAccountEndpoint APIKey:APIKey]; +- (nullable instancetype)initWitLocalID:(NSString *)localID + accessToken:(NSString *)accessToken + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration { + self = [super initWithEndpoint:kDeleteAccountEndpoint requestConfiguration:requestConfiguration]; if (self) { _localID = [localID copy]; _accessToken = [accessToken copy]; diff --git a/Firebase/Auth/Source/RPCs/FIRGetAccountInfoRequest.h b/Firebase/Auth/Source/RPCs/FIRGetAccountInfoRequest.h index b45b933..a5a8a20 100644 --- a/Firebase/Auth/Source/RPCs/FIRGetAccountInfoRequest.h +++ b/Firebase/Auth/Source/RPCs/FIRGetAccountInfoRequest.h @@ -32,19 +32,21 @@ NS_ASSUME_NONNULL_BEGIN */ @property(nonatomic, copy) NSString *accessToken; -/** @fn initWithEndpoint:APIKey: - @brief Please use initWithAPIKey:IDToken: +/** @fn initWithEndpoint:requestConfiguration:requestConfiguration + @brief Please use initWithAccessToken:requestConfiguration: instead. */ - (nullable instancetype)initWithEndpoint:(NSString *)endpoint - APIKey:(NSString *)APIKey NS_UNAVAILABLE; + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration + NS_UNAVAILABLE; -/** @fn initWithAPIKey:accessToken: +/** @fn initWithAccessToken:requestConfiguration @brief Designated initializer. - @param APIKey The client's API Key. @param accessToken The Access Token of the authenticated user. + @param requestConfiguration An object containing configurations to be added to the request. */ -- (nullable instancetype)initWithAPIKey:(NSString *)APIKey - accessToken:(NSString *)accessToken NS_DESIGNATED_INITIALIZER; +- (nullable instancetype)initWithAccessToken:(NSString *)accessToken + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration + NS_DESIGNATED_INITIALIZER; @end diff --git a/Firebase/Auth/Source/RPCs/FIRGetAccountInfoRequest.m b/Firebase/Auth/Source/RPCs/FIRGetAccountInfoRequest.m index 5c73086..fde79fb 100644 --- a/Firebase/Auth/Source/RPCs/FIRGetAccountInfoRequest.m +++ b/Firebase/Auth/Source/RPCs/FIRGetAccountInfoRequest.m @@ -29,9 +29,10 @@ static NSString *const kIDTokenKey = @"idToken"; @implementation FIRGetAccountInfoRequest -- (nullable instancetype)initWithAPIKey:(NSString *)APIKey - accessToken:(NSString *)accessToken { - self = [super initWithEndpoint:kGetAccountInfoEndpoint APIKey:APIKey]; +- (nullable instancetype)initWithAccessToken:(NSString *)accessToken + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration { + self = [super initWithEndpoint:kGetAccountInfoEndpoint + requestConfiguration:requestConfiguration]; if (self) { _accessToken = [accessToken copy]; } diff --git a/Firebase/Auth/Source/RPCs/FIRGetOOBConfirmationCodeRequest.h b/Firebase/Auth/Source/RPCs/FIRGetOOBConfirmationCodeRequest.h index 08ab495..34714e5 100644 --- a/Firebase/Auth/Source/RPCs/FIRGetOOBConfirmationCodeRequest.h +++ b/Firebase/Auth/Source/RPCs/FIRGetOOBConfirmationCodeRequest.h @@ -19,6 +19,8 @@ #import "FIRAuthRPCRequest.h" #import "FIRIdentityToolkitRequest.h" +@class FIRActionCodeSettings; + NS_ASSUME_NONNULL_BEGIN /** @enum FIRGetOOBConfirmationCodeRequestType @@ -58,29 +60,69 @@ typedef NS_ENUM(NSInteger, FIRGetOOBConfirmationCodeRequestType) { */ @property(nonatomic, copy, nullable, readonly) NSString *accessToken; +/** @property continueURL + @brief This URL represents the state/Continue URL in the form of a universal link. + */ +@property(nonatomic, copy, nullable, readonly) NSString *continueURL; + +/** @property iOSBundleID + @brief The iOS bundle Identifier, if available. + */ +@property(nonatomic, copy, nullable, readonly) NSString *iOSBundleID; + +/** @property androidPackageName + @brief The Android package name, if available. + */ +@property(nonatomic, copy, nullable, readonly) NSString *androidPackageName; + +/** @property androidMinimumVersion + @brief The minimum Android version supported, if available. + */ +@property(nonatomic, copy, nullable, readonly) NSString *androidMinimumVersion; + +/** @property androidInstallIfNotAvailable + @brief Indicates whether or not the Android app should be installed if not already available. + */ +@property(nonatomic, assign, readonly) BOOL androidInstallApp; + +/** @property handleCodeInApp + @brief Indicates whether or not the action code link will open the app directly or after being + redirected from a Firebase owned web widget. + */ +@property(assign, nonatomic) BOOL handleCodeInApp; + /** @fn passwordResetRequestWithEmail:APIKey: @brief Creates a password reset request. @param email The user's email address. - @param APIKey The client's API Key. + @param actionCodeSettings An object of FIRActionCodeSettings which specifies action code + settings to be applied to the password reset request. + @param requestConfiguration An object containing configurations to be added to the request. @return A password reset request. */ -+ (nullable FIRGetOOBConfirmationCodeRequest *)passwordResetRequestWithEmail:(NSString *)email - APIKey:(NSString *)APIKey; ++ (nullable FIRGetOOBConfirmationCodeRequest *) + passwordResetRequestWithEmail:(NSString *)email + actionCodeSettings:(nullable FIRActionCodeSettings *)actionCodeSettings + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration; /** @fn verifyEmailRequestWithAccessToken:APIKey: @brief Creates a password reset request. @param accessToken The user's STS Access Token. - @param APIKey The client's API Key. + @param actionCodeSettings An object of FIRActionCodeSettings which specifies action code + settings to be applied to the email verification request. + @param requestConfiguration An object containing configurations to be added to the request. @return A password reset request. */ + (nullable FIRGetOOBConfirmationCodeRequest *) - verifyEmailRequestWithAccessToken:(NSString *)accessToken APIKey:(NSString *)APIKey; + verifyEmailRequestWithAccessToken:(NSString *)accessToken + actionCodeSettings:(nullable FIRActionCodeSettings *)actionCodeSettings + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration; /** @fn init @brief Please use a factory method. */ - (nullable instancetype)initWithEndpoint:(NSString *)endpoint - APIKey:(NSString *)APIKey NS_UNAVAILABLE; + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration + NS_UNAVAILABLE; @end diff --git a/Firebase/Auth/Source/RPCs/FIRGetOOBConfirmationCodeRequest.m b/Firebase/Auth/Source/RPCs/FIRGetOOBConfirmationCodeRequest.m index cf0dda5..653eddd 100644 --- a/Firebase/Auth/Source/RPCs/FIRGetOOBConfirmationCodeRequest.m +++ b/Firebase/Auth/Source/RPCs/FIRGetOOBConfirmationCodeRequest.m @@ -16,13 +16,15 @@ #import "FIRGetOOBConfirmationCodeRequest.h" +#import "FIRActionCodeSettings.h" + #import "FIRAuthErrorUtils.h" #import "FIRAuth_Internal.h" /** @var kEndpoint @brief The getOobConfirmationCode endpoint name. */ -static NSString *const kEndpoint = @"getOobConfirmationCode"; +static NSString *const kGetOobConfirmationCodeEndpoint = @"getOobConfirmationCode"; /** @var kRequestTypeKey @brief The name of the required "requestType" property in the request. @@ -40,6 +42,38 @@ static NSString *const kEmailKey = @"email"; */ static NSString *const kIDTokenKey = @"idToken"; +/** @var kContinueURLKey + @brief The key for the "continue URL" value in the request. + */ +static NSString *const kContinueURLKey = @"continueUrl"; + +/** @var kIosBundeIDKey + @brief The key for the "iOS Bundle Identifier" value in the request. + */ +static NSString *const kIosBundleIDKey = @"iOSBundleId"; + +/** @var kAndroidPackageNameKey + @brief The key for the "Android Package Name" value in the request. + */ +static NSString *const kAndroidPackageNameKey = @"androidPackageName"; + +/** @var kAndroidInstallAppKey + @brief The key for the request parameter indicating whether the android app should be installed + or not. + */ +static NSString *const kAndroidInstallAppKey = @"androidInstallApp"; + +/** @var kAndroidMinimumVersionKey + @brief The key for the "minimum Android version supported" value in the request. + */ +static NSString *const kAndroidMinimumVersionKey = @"androidMinimumVersion"; + +/** @var kCanHandleCodeInAppKey + @brief The key for the request parameter indicating whether the action code can be handled in + the app or not. + */ +static NSString *const kCanHandleCodeInAppKey = @"canHandleCodeInApp"; + /** @var kPasswordResetRequestTypeValue @brief The value for the "PASSWORD_RESET" request type. */ @@ -57,12 +91,15 @@ static NSString *const kVerifyEmailRequestTypeValue = @"VERIFY_EMAIL"; @param requestType The types of OOB Confirmation Code to request. @param email The email of the user. @param accessToken The STS Access Token of the currently signed in user. - @param APIKey The client's API Key. + @param actionCodeSettings An object of FIRActionCodeSettings which specifies action code + settings to be applied to the OOB code request. + @param requestConfiguration An object containing configurations to be added to the request. */ - (nullable instancetype)initWithRequestType:(FIRGetOOBConfirmationCodeRequestType)requestType email:(nullable NSString *)email accessToken:(nullable NSString *)accessToken - APIKey:(nullable NSString *)APIKey + actionCodeSettings:(nullable FIRActionCodeSettings *)actionCodeSettings + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration NS_DESIGNATED_INITIALIZER; @end @@ -83,31 +120,45 @@ static NSString *const kVerifyEmailRequestTypeValue = @"VERIFY_EMAIL"; } } -+ (FIRGetOOBConfirmationCodeRequest *)passwordResetRequestWithEmail:(NSString *)email - APIKey:(NSString *)APIKey { ++ (FIRGetOOBConfirmationCodeRequest *) + passwordResetRequestWithEmail:(NSString *)email + actionCodeSettings:(nullable FIRActionCodeSettings *)actionCodeSettings + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration { return [[self alloc] initWithRequestType:FIRGetOOBConfirmationCodeRequestTypePasswordReset email:email accessToken:nil - APIKey:APIKey]; + actionCodeSettings:actionCodeSettings + requestConfiguration:requestConfiguration]; } + (FIRGetOOBConfirmationCodeRequest *) - verifyEmailRequestWithAccessToken:(NSString *)accessToken APIKey:(NSString *)APIKey { + verifyEmailRequestWithAccessToken:(NSString *)accessToken + actionCodeSettings:(nullable FIRActionCodeSettings *)actionCodeSettings + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration { return [[self alloc] initWithRequestType:FIRGetOOBConfirmationCodeRequestTypeVerifyEmail email:nil accessToken:accessToken - APIKey:APIKey]; + actionCodeSettings:actionCodeSettings + requestConfiguration:requestConfiguration]; } - (nullable instancetype)initWithRequestType:(FIRGetOOBConfirmationCodeRequestType)requestType email:(nullable NSString *)email accessToken:(nullable NSString *)accessToken - APIKey:(nullable NSString *)APIKey { - self = [super initWithEndpoint:kEndpoint APIKey:APIKey]; + actionCodeSettings:(nullable FIRActionCodeSettings *)actionCodeSettings + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration { + self = [super initWithEndpoint:kGetOobConfirmationCodeEndpoint + requestConfiguration:requestConfiguration]; if (self) { _requestType = requestType; _email = email; _accessToken = accessToken; + _continueURL = actionCodeSettings.URL.absoluteString; + _iOSBundleID = actionCodeSettings.iOSBundleID; + _androidPackageName = actionCodeSettings.androidPackageName; + _androidMinimumVersion = actionCodeSettings.androidMinimumVersion; + _androidInstallApp = actionCodeSettings.androidInstallIfNotAvailable; + _handleCodeInApp = actionCodeSettings.handleCodeInApp; } return self; } @@ -129,6 +180,30 @@ static NSString *const kVerifyEmailRequestTypeValue = @"VERIFY_EMAIL"; body[kIDTokenKey] = _accessToken; } + if (_continueURL) { + body[kContinueURLKey] = _continueURL; + } + + if (_iOSBundleID) { + body[kIosBundleIDKey] = _iOSBundleID; + } + + if (_androidPackageName) { + body[kAndroidPackageNameKey] = _androidPackageName; + } + + if (_androidMinimumVersion) { + body[kAndroidMinimumVersionKey] = _androidMinimumVersion; + } + + if (_androidInstallApp) { + body[kAndroidInstallAppKey] = @YES; + } + + if (_handleCodeInApp) { + body[kCanHandleCodeInAppKey] = @YES; + } + return body; } diff --git a/Firebase/Auth/Source/RPCs/FIRIdentityToolkitRequest.h b/Firebase/Auth/Source/RPCs/FIRIdentityToolkitRequest.h index 873788d..b5ca726 100644 --- a/Firebase/Auth/Source/RPCs/FIRIdentityToolkitRequest.h +++ b/Firebase/Auth/Source/RPCs/FIRIdentityToolkitRequest.h @@ -16,6 +16,10 @@ #import <Foundation/Foundation.h> +#import "FIRAuthRequestConfiguration.h" + +@class FIRAuthRequestConfiguration; + NS_ASSUME_NONNULL_BEGIN /** @class FIRIdentityToolkitRequest @@ -41,17 +45,22 @@ NS_ASSUME_NONNULL_BEGIN /** @fn initWithEndpoint:APIKey: @brief Designated initializer. @param endpoint The endpoint name. - @param APIKey The client's API Key. + @param requestConfiguration An object containing configurations to be added to the request. */ - (nullable instancetype)initWithEndpoint:(NSString *)endpoint - APIKey:(NSString *)APIKey - NS_DESIGNATED_INITIALIZER; + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration + NS_DESIGNATED_INITIALIZER; /** @fn requestURL @brief Gets the request's full URL. */ - (NSURL *)requestURL; +/** @fn requestConfiguration + @brief Gets the request's configuration. + */ +- (FIRAuthRequestConfiguration *)requestConfiguration; + @end NS_ASSUME_NONNULL_END diff --git a/Firebase/Auth/Source/RPCs/FIRIdentityToolkitRequest.m b/Firebase/Auth/Source/RPCs/FIRIdentityToolkitRequest.m index fb51a82..c897066 100644 --- a/Firebase/Auth/Source/RPCs/FIRIdentityToolkitRequest.m +++ b/Firebase/Auth/Source/RPCs/FIRIdentityToolkitRequest.m @@ -16,6 +16,8 @@ #import "FIRIdentityToolkitRequest.h" +NS_ASSUME_NONNULL_BEGIN + /** @var kAPIURLFormat @brief URL format for server API calls. */ @@ -26,14 +28,17 @@ static NSString *const kAPIURLFormat = @"https://%@/identitytoolkit/v3/relyingpa */ static NSString *gAPIHost = @"www.googleapis.com"; -@implementation FIRIdentityToolkitRequest +@implementation FIRIdentityToolkitRequest { + FIRAuthRequestConfiguration *_requestConfiguration; +} - (nullable instancetype)initWithEndpoint:(NSString *)endpoint - APIKey:(NSString *)APIKey { + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration { self = [super init]; if (self) { _endpoint = [endpoint copy]; - _APIKey = [APIKey copy]; + _APIKey = [requestConfiguration.APIKey copy]; + _requestConfiguration = requestConfiguration; } return self; } @@ -44,6 +49,10 @@ static NSString *gAPIHost = @"www.googleapis.com"; return URL; } +- (FIRAuthRequestConfiguration *)requestConfiguration { + return _requestConfiguration; +} + #pragma mark - Internal API for development + (NSString *)host { @@ -54,4 +63,6 @@ static NSString *gAPIHost = @"www.googleapis.com"; gAPIHost = host; } +NS_ASSUME_NONNULL_END + @end diff --git a/Firebase/Auth/Source/RPCs/FIRResetPasswordRequest.h b/Firebase/Auth/Source/RPCs/FIRResetPasswordRequest.h index 66b03ad..701e305 100644 --- a/Firebase/Auth/Source/RPCs/FIRResetPasswordRequest.h +++ b/Firebase/Auth/Source/RPCs/FIRResetPasswordRequest.h @@ -33,21 +33,23 @@ NS_ASSUME_NONNULL_BEGIN */ @property(nonatomic, copy, readonly) NSString *updatedPassword; -/** @fn initWithEndpoint:APIKey: - @brief Please use initWithOOBCode:oobCode: instead. +/** @fn initWithEndpoint:requestConfiguration: + @brief Please use initWithOobCode:newPassword:requestConfiguration: instead. */ - (nullable instancetype)initWithEndpoint:(NSString *)endpoint - APIKey:(NSString *)APIKey NS_UNAVAILABLE; + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration + NS_UNAVAILABLE; -/** @fn initWithAPIKey:oobCode:currentPassword: +/** @fn initWithOobCode:newPassword:requestConfiguration: @brief Designated initializer. - @param APIKey The client's API Key. @param oobCode The OOB Code. @param newPassword The new password. + @param requestConfiguration An object containing configurations to be added to the request. */ -- (nullable instancetype)initWithAPIKey:(NSString *)APIKey - oobCode:(NSString *)oobCode - newPassword:(nullable NSString *)newPassword NS_DESIGNATED_INITIALIZER; +- (nullable instancetype)initWithOobCode:(NSString *)oobCode + newPassword:(nullable NSString *)newPassword + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration; + @end NS_ASSUME_NONNULL_END diff --git a/Firebase/Auth/Source/RPCs/FIRResetPasswordRequest.m b/Firebase/Auth/Source/RPCs/FIRResetPasswordRequest.m index 603aa00..27d6d8c 100644 --- a/Firebase/Auth/Source/RPCs/FIRResetPasswordRequest.m +++ b/Firebase/Auth/Source/RPCs/FIRResetPasswordRequest.m @@ -33,10 +33,10 @@ static NSString *const kCurrentPasswordKey = @"newPassword"; @implementation FIRResetPasswordRequest -- (instancetype)initWithAPIKey:(NSString *)APIKey - oobCode:(NSString *)oobCode - newPassword:(NSString *)newPassword { - self = [super initWithEndpoint:kResetPasswordEndpoint APIKey:APIKey]; +- (instancetype)initWithOobCode:(NSString *)oobCode + newPassword:(NSString *)newPassword + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration { + self = [super initWithEndpoint:kResetPasswordEndpoint requestConfiguration:requestConfiguration]; if (self) { _oobCode = oobCode; _updatedPassword = newPassword; diff --git a/Firebase/Auth/Source/RPCs/FIRSecureTokenRequest.h b/Firebase/Auth/Source/RPCs/FIRSecureTokenRequest.h index 44c16b1..14722fa 100644 --- a/Firebase/Auth/Source/RPCs/FIRSecureTokenRequest.h +++ b/Firebase/Auth/Source/RPCs/FIRSecureTokenRequest.h @@ -71,19 +71,22 @@ typedef NS_ENUM(NSUInteger, FIRSecureTokenRequestGrantType) { /** @fn authCodeRequestWithCode: @brief Creates an authorization code request with the given code (legacy Gitkit "ID Token"). @param code The authorization code (legacy Gitkit "ID Token"). - @param APIKey The client's API Key. + @param requestConfiguration An object containing configurations to be added to the request. @return An authorization request. */ -+ (FIRSecureTokenRequest *)authCodeRequestWithCode:(NSString *)code APIKey:(NSString *)APIKey; ++ (FIRSecureTokenRequest *)authCodeRequestWithCode:(NSString *)code + requestConfiguration:(FIRAuthRequestConfiguration *) + requestConfiguration; /** @fn refreshRequestWithCode: @brief Creates a refresh request with the given refresh token. @param refreshToken The refresh token. - @param APIKey The client's API Key. + @param requestConfiguration An object containing configurations to be added to the request. @return A refresh request. */ + (FIRSecureTokenRequest *)refreshRequestWithRefreshToken:(NSString *)refreshToken - APIKey:(NSString *)APIKey; + requestConfiguration:(FIRAuthRequestConfiguration *) + requestConfiguration; /** @fn init @brief Please use initWithGrantType:scope:refreshToken:code: @@ -96,13 +99,14 @@ typedef NS_ENUM(NSUInteger, FIRSecureTokenRequestGrantType) { @param scope The scopes requested. @param refreshToken The client's refresh token (for refresh requests.) @param code The client's authorization code (Gitkit ID Token) (for authorization code requests.) - @param APIKey The client's API Key. + @param requestConfiguration An object containing configurations to be added to the request. */ - (nullable instancetype)initWithGrantType:(FIRSecureTokenRequestGrantType)grantType scope:(nullable NSString *)scope refreshToken:(nullable NSString *)refreshToken code:(nullable NSString *)code - APIKey:(NSString *)APIKey NS_DESIGNATED_INITIALIZER; + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration + NS_DESIGNATED_INITIALIZER; @end diff --git a/Firebase/Auth/Source/RPCs/FIRSecureTokenRequest.m b/Firebase/Auth/Source/RPCs/FIRSecureTokenRequest.m index 1983542..9c39e1e 100644 --- a/Firebase/Auth/Source/RPCs/FIRSecureTokenRequest.m +++ b/Firebase/Auth/Source/RPCs/FIRSecureTokenRequest.m @@ -15,6 +15,7 @@ */ #import "FIRSecureTokenRequest.h" +#import "FIRAuthRequestConfiguration.h" /** @var kFIRSecureTokenServiceGetTokenURLFormat @brief The format of the secure token service URLs. Requires string format substitution with @@ -57,23 +58,31 @@ static NSString *const kCodeKey = @"code"; */ static NSString *gAPIHost = @"securetoken.googleapis.com"; -@implementation FIRSecureTokenRequest +@implementation FIRSecureTokenRequest { + /** @var _requestConfiguration + @brief Contains configuration relevant to the request. + */ + FIRAuthRequestConfiguration *_requestConfiguration; +} -+ (FIRSecureTokenRequest *)authCodeRequestWithCode:(NSString *)code APIKey:(NSString *)APIKey { ++ (FIRSecureTokenRequest *)authCodeRequestWithCode:(NSString *)code + requestConfiguration:(FIRAuthRequestConfiguration *) + requestConfiguration { return [[self alloc] initWithGrantType:FIRSecureTokenRequestGrantTypeAuthorizationCode scope:nil refreshToken:nil code:code - APIKey:APIKey]; + requestConfiguration:requestConfiguration]; } + (FIRSecureTokenRequest *)refreshRequestWithRefreshToken:(NSString *)refreshToken - APIKey:(NSString *)APIKey { + requestConfiguration:(FIRAuthRequestConfiguration *) + requestConfiguration { return [[self alloc] initWithGrantType:FIRSecureTokenRequestGrantTypeRefreshToken scope:nil refreshToken:refreshToken code:nil - APIKey:APIKey]; + requestConfiguration:requestConfiguration]; } /** @fn grantTypeStringWithGrantType: @@ -93,18 +102,23 @@ static NSString *gAPIHost = @"securetoken.googleapis.com"; scope:(nullable NSString *)scope refreshToken:(nullable NSString *)refreshToken code:(nullable NSString *)code - APIKey:(NSString *)APIKey { + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration { self = [super init]; if (self) { _grantType = grantType; _scope = [scope copy]; _refreshToken = [refreshToken copy]; _code = [code copy]; - _APIKey = [APIKey copy]; + _APIKey = [requestConfiguration.APIKey copy]; + _requestConfiguration = requestConfiguration; } return self; } +- (FIRAuthRequestConfiguration *)requestConfiguration { + return _requestConfiguration; +} + - (NSURL *)requestURL { NSString *URLString = [NSString stringWithFormat:kFIRSecureTokenServiceGetTokenURLFormat, gAPIHost, _APIKey]; diff --git a/Firebase/Auth/Source/RPCs/FIRSendVerificationCodeRequest.h b/Firebase/Auth/Source/RPCs/FIRSendVerificationCodeRequest.h index 596fb8c..9a5c41c 100644 --- a/Firebase/Auth/Source/RPCs/FIRSendVerificationCodeRequest.h +++ b/Firebase/Auth/Source/RPCs/FIRSendVerificationCodeRequest.h @@ -35,21 +35,24 @@ NS_ASSUME_NONNULL_BEGIN */ @property(nonatomic, strong, readonly) FIRAuthAppCredential *appCredential; -/** @fn initWithEndpoint:APIKey: - @brief Please use initWithPhoneNumber:APIKey: +/** @fn initWithEndpoint:requestConfiguration: + @brief Please use initWithPhoneNumber:appCredentials:requestConfiguration: instead. */ - (nullable instancetype)initWithEndpoint:(NSString *)endpoint - APIKey:(NSString *)APIKey NS_UNAVAILABLE; + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration + NS_UNAVAILABLE; -/** @fn initWithPhoneNumber:APIKey: +/** @fn initWithPhoneNumber:appCredentials:requestConfiguration: @brief Designated initializer. @param phoneNumber The phone number to which the verification code is to be sent. @param appCredential The credential that proves the identity of the app. - @param APIKey The client's API Key. + @param requestConfiguration An object containing configurations to be added to the request. */ - (nullable instancetype)initWithPhoneNumber:(NSString *)phoneNumber appCredential:(FIRAuthAppCredential *)appCredential - APIKey:(NSString *)APIKey NS_DESIGNATED_INITIALIZER; + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration + NS_DESIGNATED_INITIALIZER; + @end diff --git a/Firebase/Auth/Source/RPCs/FIRSendVerificationCodeRequest.m b/Firebase/Auth/Source/RPCs/FIRSendVerificationCodeRequest.m index d97c90a..2f33e02 100644 --- a/Firebase/Auth/Source/RPCs/FIRSendVerificationCodeRequest.m +++ b/Firebase/Auth/Source/RPCs/FIRSendVerificationCodeRequest.m @@ -45,8 +45,9 @@ static NSString *const kSecretKey = @"iosSecret"; - (nullable instancetype)initWithPhoneNumber:(NSString *)phoneNumber appCredential:(FIRAuthAppCredential *)appCredential - APIKey:(NSString *)APIKey { - self = [super initWithEndpoint:kSendVerificationCodeEndPoint APIKey:APIKey]; + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration { + self = [super initWithEndpoint:kSendVerificationCodeEndPoint + requestConfiguration:requestConfiguration]; if (self) { _phoneNumber = [phoneNumber copy]; _appCredential = appCredential; diff --git a/Firebase/Auth/Source/RPCs/FIRSetAccountInfoRequest.h b/Firebase/Auth/Source/RPCs/FIRSetAccountInfoRequest.h index 4816474..0e0e18f 100644 --- a/Firebase/Auth/Source/RPCs/FIRSetAccountInfoRequest.h +++ b/Firebase/Auth/Source/RPCs/FIRSetAccountInfoRequest.h @@ -132,17 +132,19 @@ extern NSString *const FIRSetAccountInfoUserAttributePassword; */ @property(nonatomic, assign) BOOL returnSecureToken; -/** @fn initWithEndpoint:APIKey: - @brief Please use initWithAPIKey: +/** @fn initWithEndpoint:requestConfiguration: + @brief Please use initWithAPIKey:email:password:displayName:requestConfiguration instead. */ - (nullable instancetype)initWithEndpoint:(NSString *)endpoint - APIKey:(NSString *)APIKey NS_UNAVAILABLE; + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration + NS_UNAVAILABLE; -/** @fn initWithAPIKey: +/** @fn initWithRequestConfiguration: @brief Designated initializer. - @param APIKey The client's API Key. + @param requestConfiguration An object containing configurations to be added to the request. */ -- (nullable instancetype)initWithAPIKey:(NSString *)APIKey NS_DESIGNATED_INITIALIZER; +- (nullable instancetype)initWithRequestConfiguration: + (FIRAuthRequestConfiguration *)requestConfiguration NS_DESIGNATED_INITIALIZER; @end diff --git a/Firebase/Auth/Source/RPCs/FIRSetAccountInfoRequest.m b/Firebase/Auth/Source/RPCs/FIRSetAccountInfoRequest.m index 5b202a4..f455d47 100644 --- a/Firebase/Auth/Source/RPCs/FIRSetAccountInfoRequest.m +++ b/Firebase/Auth/Source/RPCs/FIRSetAccountInfoRequest.m @@ -113,8 +113,9 @@ static NSString *const kReturnSecureTokenKey = @"returnSecureToken"; @implementation FIRSetAccountInfoRequest -- (nullable instancetype)initWithAPIKey:(NSString *)APIKey { - self = [super initWithEndpoint:kSetAccountInfoEndpoint APIKey:APIKey]; +- (nullable instancetype)initWithRequestConfiguration: + (FIRAuthRequestConfiguration *)requestConfiguration { + self = [super initWithEndpoint:kSetAccountInfoEndpoint requestConfiguration:requestConfiguration]; if (self) { _returnSecureToken = YES; } diff --git a/Firebase/Auth/Source/RPCs/FIRSignUpNewUserRequest.h b/Firebase/Auth/Source/RPCs/FIRSignUpNewUserRequest.h index 46b47d5..06d2cfe 100644 --- a/Firebase/Auth/Source/RPCs/FIRSignUpNewUserRequest.h +++ b/Firebase/Auth/Source/RPCs/FIRSignUpNewUserRequest.h @@ -44,23 +44,28 @@ NS_ASSUME_NONNULL_BEGIN */ @property(nonatomic, assign) BOOL returnSecureToken; -/** @fn initWithEndpoint:APIKey: - @brief Please use initWithEmail:password:APIKey: +/** @fn initWithEndpoint:requestConfiguration: + @brief Please use initWithAPIKey:email:password:displayName:requestConfiguration instead. */ - (nullable instancetype)initWithEndpoint:(NSString *)endpoint - APIKey:(NSString *)APIKey NS_UNAVAILABLE; -/** @fn initWithAPIKey: + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration + NS_UNAVAILABLE; + +/** @fn initWithEndpoint:requestConfiguration: @brief initializer for anonymous sign-in. */ -- (nullable instancetype)initWithAPIKey:(NSString *)APIKey; +- (nullable instancetype)initWithRequestConfiguration: + (FIRAuthRequestConfiguration *)requestConfiguration; -/** @fn initWithAPIKey:email:password: +/** @fn initWithAPIKey:email:password:displayName:requestConfiguration @brief Designated initializer. + @param requestConfiguration An object containing configurations to be added to the request. */ -- (nullable instancetype)initWithAPIKey:(NSString *)APIKey - email:(nullable NSString *)email - password:(nullable NSString *)password - displayName:(nullable NSString *)displayName NS_DESIGNATED_INITIALIZER; +- (nullable instancetype)initWithEmail:(nullable NSString *)email + password:(nullable NSString *)password + displayName:(nullable NSString *)displayName + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration + NS_DESIGNATED_INITIALIZER; @end diff --git a/Firebase/Auth/Source/RPCs/FIRSignUpNewUserRequest.m b/Firebase/Auth/Source/RPCs/FIRSignUpNewUserRequest.m index af60b11..52a0215 100644 --- a/Firebase/Auth/Source/RPCs/FIRSignUpNewUserRequest.m +++ b/Firebase/Auth/Source/RPCs/FIRSignUpNewUserRequest.m @@ -43,11 +43,11 @@ static NSString *const kReturnSecureTokenKey = @"returnSecureToken"; @implementation FIRSignUpNewUserRequest -- (nullable instancetype)initWithAPIKey:(NSString *)APIKey - email:(NSString *)email - password:(NSString *)password - displayName:(NSString *)displayName { - self = [super initWithEndpoint:kSignupNewUserEndpoint APIKey:APIKey]; +- (nullable instancetype)initWithEmail:(nullable NSString *)email + password:(nullable NSString *)password + displayName:(nullable NSString *)displayName + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration { + self = [super initWithEndpoint:kSignupNewUserEndpoint requestConfiguration:requestConfiguration]; if (self) { _email = [email copy]; _password = [password copy]; @@ -57,8 +57,12 @@ static NSString *const kReturnSecureTokenKey = @"returnSecureToken"; return self; } -- (nullable instancetype)initWithAPIKey:(NSString *)APIKey{ - self = [self initWithAPIKey:APIKey email:nil password:nil displayName:nil]; +- (nullable instancetype)initWithRequestConfiguration: + (FIRAuthRequestConfiguration *)requestConfiguration { + self = [self initWithEmail:nil + password:nil + displayName:nil + requestConfiguration:requestConfiguration]; return self; } diff --git a/Firebase/Auth/Source/RPCs/FIRVerifyAssertionRequest.h b/Firebase/Auth/Source/RPCs/FIRVerifyAssertionRequest.h index 3202b47..3136b80 100644 --- a/Firebase/Auth/Source/RPCs/FIRVerifyAssertionRequest.h +++ b/Firebase/Auth/Source/RPCs/FIRVerifyAssertionRequest.h @@ -81,19 +81,22 @@ NS_ASSUME_NONNULL_BEGIN */ @property(nonatomic, assign) BOOL autoCreate; -/** @fn initWithEndpoint:APIKey: - @brief Please use initWithAPIKey: +/** @fn initWithEndpoint:requestConfiguration: + @brief Please use initWithProviderID:requestConfifuration instead. */ - (nullable instancetype)initWithEndpoint:(NSString *)endpoint - APIKey:(NSString *)APIKey NS_UNAVAILABLE; + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration + NS_UNAVAILABLE; -/** @fn initWithAPIKey: +/** @fn initWithProviderID:requestConfifuration @brief Designated initializer. - @param APIKey The client's API Key. @param providerID The auth provider's ID. + @param requestConfiguration An object containing configurations to be added to the request. + */ -- (nullable instancetype)initWithAPIKey:(NSString *)APIKey - providerID:(NSString *)providerID NS_DESIGNATED_INITIALIZER; +- (nullable instancetype)initWithProviderID:(NSString *)providerID + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration + NS_DESIGNATED_INITIALIZER; @end diff --git a/Firebase/Auth/Source/RPCs/FIRVerifyAssertionRequest.m b/Firebase/Auth/Source/RPCs/FIRVerifyAssertionRequest.m index b31ae42..2251c42 100644 --- a/Firebase/Auth/Source/RPCs/FIRVerifyAssertionRequest.m +++ b/Firebase/Auth/Source/RPCs/FIRVerifyAssertionRequest.m @@ -82,9 +82,10 @@ static NSString *const kReturnSecureTokenKey = @"returnSecureToken"; @implementation FIRVerifyAssertionRequest -- (nullable instancetype)initWithAPIKey:(NSString *)APIKey - providerID:(nonnull NSString *)providerID{ - self = [super initWithEndpoint:kVerifyAssertionEndpoint APIKey:APIKey]; +- (nullable instancetype)initWithProviderID:(NSString *)providerID + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration { + self = [super initWithEndpoint:kVerifyAssertionEndpoint + requestConfiguration:requestConfiguration]; if (self) { _providerID = providerID; _returnSecureToken = YES; diff --git a/Firebase/Auth/Source/RPCs/FIRVerifyClientRequest.h b/Firebase/Auth/Source/RPCs/FIRVerifyClientRequest.h index b5da6b8..b6732a4 100644 --- a/Firebase/Auth/Source/RPCs/FIRVerifyClientRequest.h +++ b/Firebase/Auth/Source/RPCs/FIRVerifyClientRequest.h @@ -32,21 +32,24 @@ NS_ASSUME_NONNULL_BEGIN */ @property(nonatomic, assign, readonly) BOOL isSandbox; -/** @fn initWithEndpoint:APIKey: - @brief Please use initWithAppToken:isSandbox: instead. +/** @fn initWithEndpoint:requestConfiguration: + @brief Please use initWithToken:requestConfiguration: instead. */ - (nullable instancetype)initWithEndpoint:(NSString *)endpoint - APIKey:(NSString *)APIKey NS_UNAVAILABLE; + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration + NS_UNAVAILABLE; -/** @fn initWithAppToken:isSandbox: +/** @fn initWithAppToken:isSandbox:requestConfiguration: @brief Designated initializer. @param appToken The APNS device token. @param isSandbox The flag indicating whether or not the app token provided is for Sandbox or Production. + @param requestConfiguration An object containing configurations to be added to the request. */ - (nullable instancetype)initWithAppToken:(NSString *)appToken isSandbox:(BOOL)isSandbox - APIKey:(NSString *)APIKey NS_DESIGNATED_INITIALIZER; + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration + NS_DESIGNATED_INITIALIZER; @end diff --git a/Firebase/Auth/Source/RPCs/FIRVerifyClientRequest.m b/Firebase/Auth/Source/RPCs/FIRVerifyClientRequest.m index 7b4b469..4a102e6 100644 --- a/Firebase/Auth/Source/RPCs/FIRVerifyClientRequest.m +++ b/Firebase/Auth/Source/RPCs/FIRVerifyClientRequest.m @@ -38,8 +38,8 @@ static NSString *const kIsSandboxKey = @"isSandbox"; - (nullable instancetype)initWithAppToken:(NSString *)appToken isSandbox:(BOOL)isSandbox - APIKey:(NSString *)APIKey { - self = [super initWithEndpoint:kVerifyClientEndpoint APIKey:APIKey]; + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration { + self = [super initWithEndpoint:kVerifyClientEndpoint requestConfiguration:requestConfiguration]; if (self) { _appToken = appToken; _isSandbox = isSandbox; diff --git a/Firebase/Auth/Source/RPCs/FIRVerifyCustomTokenRequest.h b/Firebase/Auth/Source/RPCs/FIRVerifyCustomTokenRequest.h index 20f3f4d..84bad05 100644 --- a/Firebase/Auth/Source/RPCs/FIRVerifyCustomTokenRequest.h +++ b/Firebase/Auth/Source/RPCs/FIRVerifyCustomTokenRequest.h @@ -37,19 +37,20 @@ NS_ASSUME_NONNULL_BEGIN */ @property(nonatomic, assign) BOOL returnSecureToken; -/** @fn initWithEndpoint:APIKey: - @brief Please use initWithToken:APIKey: +/** @fn initWithEndpoint:requestConfiguration: + @brief Please use initWithToken:requestConfiguration: instead. */ -- (nullable instancetype)initWithEndpoint:(NSString *)endpoint - APIKey:(NSString *)APIKey NS_UNAVAILABLE; +- (nullable instancetype)initWithEndpoint:(NSString *)endpoint requestConfiguration: + (FIRAuthRequestConfiguration *)requestConfiguration NS_UNAVAILABLE; -/** @fn initWithToken:APIKey: +/** @fn initWithToken:requestConfiguration: @brief Designated initializer. @param token The self-signed token from the client's BYOAuth server. - @param APIKey The client's API Key. + @param requestConfiguration An object containing configurations to be added to the request. */ - (nullable instancetype)initWithToken:(NSString *)token - APIKey:(NSString *)APIKey NS_DESIGNATED_INITIALIZER; + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration + NS_DESIGNATED_INITIALIZER; @end diff --git a/Firebase/Auth/Source/RPCs/FIRVerifyCustomTokenRequest.m b/Firebase/Auth/Source/RPCs/FIRVerifyCustomTokenRequest.m index 63d72d1..79e60f4 100644 --- a/Firebase/Auth/Source/RPCs/FIRVerifyCustomTokenRequest.m +++ b/Firebase/Auth/Source/RPCs/FIRVerifyCustomTokenRequest.m @@ -34,8 +34,9 @@ static NSString *const kReturnSecureTokenKey = @"returnSecureToken"; @implementation FIRVerifyCustomTokenRequest - (nullable instancetype)initWithToken:(NSString *)token - APIKey:(NSString *)APIKey { - self = [super initWithEndpoint:kVerifyCustomTokenEndpoint APIKey:APIKey]; + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration { + self = [super initWithEndpoint:kVerifyCustomTokenEndpoint + requestConfiguration:requestConfiguration]; if (self) { _token = [token copy]; _returnSecureToken = YES; diff --git a/Firebase/Auth/Source/RPCs/FIRVerifyPasswordRequest.h b/Firebase/Auth/Source/RPCs/FIRVerifyPasswordRequest.h index ba54bce..39eb388 100644 --- a/Firebase/Auth/Source/RPCs/FIRVerifyPasswordRequest.h +++ b/Firebase/Auth/Source/RPCs/FIRVerifyPasswordRequest.h @@ -58,21 +58,23 @@ NS_ASSUME_NONNULL_BEGIN */ @property(nonatomic, assign) BOOL returnSecureToken; -/** @fn initWithEndpoint:APIKey: - @brief Please use initWithEmail:password:APIKey: +/** @fn initWithEndpoint:requestConfiguration: + @brief Please use initWithEmail:password:requestConfiguration: */ - (nullable instancetype)initWithEndpoint:(NSString *)endpoint - APIKey:(NSString *)APIKey NS_UNAVAILABLE; + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration + NS_UNAVAILABLE; -/** @fn initWithEmail:password:APIKey: +/** @fn initWithEmail:password:requestConfiguration: @brief Designated initializer. @param email The email of the user. @param password The password inputed by the user. - @param APIKey The client's API Key. + @param requestConfiguration The configu */ - (nullable instancetype)initWithEmail:(NSString *)email password:(NSString *)password - APIKey:(NSString *)APIKey NS_DESIGNATED_INITIALIZER; + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration + NS_DESIGNATED_INITIALIZER; @end diff --git a/Firebase/Auth/Source/RPCs/FIRVerifyPasswordRequest.m b/Firebase/Auth/Source/RPCs/FIRVerifyPasswordRequest.m index 7a9da8b..515a425 100644 --- a/Firebase/Auth/Source/RPCs/FIRVerifyPasswordRequest.m +++ b/Firebase/Auth/Source/RPCs/FIRVerifyPasswordRequest.m @@ -55,8 +55,9 @@ static NSString *const kReturnSecureTokenKey = @"returnSecureToken"; - (nullable instancetype)initWithEmail:(NSString *)email password:(NSString *)password - APIKey:(NSString *)APIKey { - self = [super initWithEndpoint:kVerifyPasswordEndpoint APIKey:APIKey]; + requestConfiguration:(nonnull FIRAuthRequestConfiguration *)requestConfiguration { + self = [super initWithEndpoint:kVerifyPasswordEndpoint + requestConfiguration:requestConfiguration]; if (self) { _email = [email copy]; _password = [password copy]; diff --git a/Firebase/Auth/Source/RPCs/FIRVerifyPhoneNumberRequest.h b/Firebase/Auth/Source/RPCs/FIRVerifyPhoneNumberRequest.h index 06039b9..b091d62 100644 --- a/Firebase/Auth/Source/RPCs/FIRVerifyPhoneNumberRequest.h +++ b/Firebase/Auth/Source/RPCs/FIRVerifyPhoneNumberRequest.h @@ -47,31 +47,34 @@ NS_ASSUME_NONNULL_BEGIN */ @property(nonatomic, readonly, nonnull) NSString *phoneNumber; -/** @fn initWithEndpoint:APIKey: - @brief Please use initWithPhoneNumber:APIKey: +/** @fn initWithEndpoint:requestConfiguration: + @brief Please use initWithVerificationID:verificationCode:requestConfiguration */ - (nullable instancetype)initWithEndpoint:(NSString *)endpoint - APIKey:(NSString *)APIKey NS_UNAVAILABLE; + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration + NS_UNAVAILABLE; /** @fn initWithTemporaryProof:phoneNumberAPIKey @brief Designated initializer. @param temporaryProof The temporary proof sent by the backed. @param phoneNumber The phone number associated with the credential to be signed in. - @param APIKey The client's API Key. + @param requestConfiguration An object containing configurations to be added to the request. */ - (nullable instancetype)initWithTemporaryProof:(NSString *)temporaryProof phoneNumber:(NSString *)phoneNumber - APIKey:(NSString *)APIKey NS_DESIGNATED_INITIALIZER; + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration + NS_DESIGNATED_INITIALIZER; -/** @fn initWithVerificationID:verificationCode:APIKey +/** @fn initWithVerificationID:verificationCode:requestConfiguration @brief Designated initializer. @param verificationID The verification ID obtained from the response of @c sendVerificationCode. @param verificationCode The verification code provided by the user. - @param APIKey The client's API Key. + @param requestConfiguration An object containing configurations to be added to the request. */ - (nullable instancetype)initWithVerificationID:(NSString *)verificationID verificationCode:(NSString *)verificationCode - APIKey:(NSString *)APIKey NS_DESIGNATED_INITIALIZER; + requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration + NS_DESIGNATED_INITIALIZER; @end diff --git a/Firebase/Auth/Source/RPCs/FIRVerifyPhoneNumberRequest.m b/Firebase/Auth/Source/RPCs/FIRVerifyPhoneNumberRequest.m index b3d1054..b859693 100644 --- a/Firebase/Auth/Source/RPCs/FIRVerifyPhoneNumberRequest.m +++ b/Firebase/Auth/Source/RPCs/FIRVerifyPhoneNumberRequest.m @@ -52,8 +52,10 @@ static NSString *const kPhoneNumberKey = @"phoneNumber"; - (nullable instancetype)initWithTemporaryProof:(NSString *)temporaryProof phoneNumber:(NSString *)phoneNumber - APIKey:(NSString *)APIKey { - self = [super initWithEndpoint:kVerifyPhoneNumberEndPoint APIKey:APIKey]; + requestConfiguration: + (FIRAuthRequestConfiguration *)requestConfiguration { + self = [super initWithEndpoint:kVerifyPhoneNumberEndPoint + requestConfiguration:requestConfiguration]; if (self) { _temporaryProof = [temporaryProof copy]; _phoneNumber = [phoneNumber copy]; @@ -63,8 +65,10 @@ static NSString *const kPhoneNumberKey = @"phoneNumber"; - (nullable instancetype)initWithVerificationID:(NSString *)verificationID verificationCode:(NSString *)verificationCode - APIKey:(NSString *)APIKey { - self = [super initWithEndpoint:kVerifyPhoneNumberEndPoint APIKey:APIKey]; + requestConfiguration: + (FIRAuthRequestConfiguration *)requestConfiguration { + self = [super initWithEndpoint:kVerifyPhoneNumberEndPoint + requestConfiguration:requestConfiguration]; if (self) { _verificationID = verificationID; _verificationCode = verificationCode; |