adding pods method of package managing
This commit is contained in:
+315
@@ -0,0 +1,315 @@
|
||||
# 8.9.0
|
||||
- [changed] Improved error logging. (#8704)
|
||||
- [added] Added MFA support for email link sign-in. (#8705)
|
||||
|
||||
# 8.8.0
|
||||
- [fixed] Fall back to reCAPTCHA for phone auth app verification if the push notification is not received before the timeout. (#8653)
|
||||
|
||||
# 8.6.0
|
||||
- [fixed] Annotated platform-level availability using `API_UNAVAILABLE` instead of conditionally compiling certain methods with `#if` directives. (#8451)
|
||||
|
||||
# 8.5.0
|
||||
- [fixed] Fixed an analyze issue introduced in Xcode 12.5. (#8411)
|
||||
|
||||
# 8.2.0
|
||||
- [fixed] Fixed analyze issues introduced in Xcode 12.5. (#8210)
|
||||
- [fixed] Fixed a bug in the link with email link, Game Center, and phone auth flows. (#8196)
|
||||
|
||||
# 8.0.0
|
||||
- [fixed] Fixed a crash that occurred when assigning auth settings. (#7670)
|
||||
|
||||
# 7.8.0
|
||||
- [fixed] Fixed auth state sharing during first app launch. (#7472)
|
||||
|
||||
# 7.6.0
|
||||
- [fixed] Auth emulator now works across the local network. (#7350)
|
||||
- [fixed] Fixed incorrect import for watchOS (#7425)
|
||||
|
||||
# 7.4.0
|
||||
- [fixed] Check if the reverse client ID is configured as a custom URL scheme before setting it as the callback scheme. (#7211)
|
||||
- [added] Add ability to sync auth state across devices. (#6924)
|
||||
- [fixed] Add multi-tenancy support for email link sign-in. (#7246)
|
||||
|
||||
# 7.3.0
|
||||
- [fixed] Catalyst browser issue with `verifyPhoneNumber` API. (#7049)
|
||||
|
||||
# 7.1.0
|
||||
- [fixed] Fixed completion handler issue in `application(_:didReceiveRemoteNotification:fetchCompletionHandler:)` method. (#6863)
|
||||
|
||||
# 7.0.0
|
||||
- [removed] Remove deprecated APIs `dataForKey`,`fetchProvidersForEmail:completion`, `signInAndRetrieveDataWithCredential:completion`, `reauthenticateAndRetrieveDataWithCredential:completion`, `linkAndRetrieveDataWithCredential:completion`. (#6607)
|
||||
- [added] Add support for the auth emulator. (#6624)
|
||||
- [changed] The global variables `FirebaseAuthVersionNum` and `FirebaseAuthVersionStr` are deleted.
|
||||
`FirebaseVersion()` or `FIRFirebaseVersion()` should be used instead.
|
||||
|
||||
# v6.9.1
|
||||
- [fixed] Internal source documentation. (#6371)
|
||||
|
||||
# v6.9.0
|
||||
- [added] Added support for multi-tenancy (#6142).
|
||||
- [added] Added basic watchOS support. (#4621)
|
||||
- [changed] Improved Xcode completion of public API completion handlers in Swift. (#6283)
|
||||
|
||||
# v6.8.0
|
||||
- [fixed] Fix bug where multiple keychain entries would result in user persistence failure. (#5906)
|
||||
- [changed] Added support for using GOOGLE_APP_ID in generic IDP and phone auth reCAPTCHA fallback flows. (#6121)
|
||||
|
||||
# v6.7.1
|
||||
- [fixed] Fixed a multithreaded memory access issue on iOS. (#5979)
|
||||
|
||||
# v6.7.0
|
||||
- [changed] Functionally neutral source reorganization for preliminary Swift Package Manager support. (#5856)
|
||||
|
||||
# v6.5.3
|
||||
- [changed] Remove unused mfa request field "mfa_provider" (#5397)
|
||||
- [fixed] Suppress deprecation warnings when targeting iOS versions up to iOS 13. (#5437)
|
||||
|
||||
# v6.5.2
|
||||
- [fixed] Handle calls to `useUserAccessGroup` soon after configure. (#4175)
|
||||
|
||||
# v6.5.1
|
||||
- [changed] File structure changes. No functional change.
|
||||
- [changed] Code formatting changes.
|
||||
|
||||
# v6.5.0
|
||||
- [feature] Added support of Multi-factor Authentication. (#4823)
|
||||
|
||||
# v6.4.1
|
||||
- [fixed] Added support of UISceneDelegate for URL redirect. (#4380)
|
||||
- [fixed] Fixed rawNonce in encoder. (#4337)
|
||||
|
||||
# v6.4.0
|
||||
- [feature] Added support for Sign-in with Apple. (#4183)
|
||||
|
||||
# v6.3.1
|
||||
- [fixed] Removed usage of a deprecated property on iOS 13. (#4066)
|
||||
|
||||
# v6.3.0
|
||||
- [added] Added methods allowing developers to link and reauthenticate with federated providers. (#3971)
|
||||
|
||||
# v6.2.3
|
||||
- [fixed] Make sure the first valid auth domain is retrieved. (#3493)
|
||||
- [fixed] Add assertion for Facebook generic IDP flow. (#3208)
|
||||
- [fixed] Build for Catalyst. (#3549)
|
||||
|
||||
# v6.2.2
|
||||
- [fixed] Fixed an issue where unlinking an email auth provider raised an incorrect error stating the account was not linked to an email auth provider. (#3405)
|
||||
- [changed] Renamed internal Keychain classes. (#3473)
|
||||
|
||||
# v6.2.1
|
||||
- [added] Add new client error MISSING_CLIENT_IDENTIFIER. (#3341)
|
||||
|
||||
# v6.2.0
|
||||
- [feature] Expose `secret` of OAuth credential in public header. (#3089)
|
||||
- [fixed] Fix a keychain issue where API key is incorrectly set. (#3239)
|
||||
|
||||
# v6.1.2
|
||||
- [fixed] Fix line limits and linter warnings in public documentation. (#3139)
|
||||
|
||||
# v6.1.1
|
||||
- [fixed] Fix an issue where a user can't link with email provider by email link. (#3030)
|
||||
|
||||
# v6.1.0
|
||||
- [added] Add support of web.app as an auth domain. (#2959)
|
||||
- [fixed] Fix an issue where the return type of `getStoredUserForAccessGroup:error:` is nonnull. (#2879)
|
||||
|
||||
# v6.0.0
|
||||
- [added] Add support of single sign on. (#2684)
|
||||
- [deprecated] Deprecate `reauthenticateAndRetrieveDataWithCredential:completion:`, `signInAndRetrieveDataWithCredential:completion:`, `linkAndRetrieveDataWithCredential:completion:`, `fetchProvidersForEmail:completion:`. (#2723, #2756)
|
||||
- [added] Returned oauth secret token in Generic IDP sign-in for Twitter. (#2663)
|
||||
- [removed] Remove pendingToken from public API. (#2676)
|
||||
- [changed] `GULAppDelegateSwizzler` is used for the app delegate swizzling. (#2591)
|
||||
|
||||
# v5.4.2
|
||||
- [added] Support new error code ERROR_INVALID_PROVIDER_ID. (#2629)
|
||||
|
||||
# v5.4.1
|
||||
- [deprecated] Deprecate Microsoft and Yahoo OAuth Provider ID (#2517)
|
||||
- [fixed] Fix an issue where an exception was thrown when linking OAuth credentials. (#2521)
|
||||
- [fixed] Fix an issue where a wrong error was thrown when handling error with
|
||||
FEDERATED_USER_ID_ALREADY_LINKED. (#2522)
|
||||
|
||||
# v5.4.0
|
||||
- [added] Add support of Generic IDP (#2405).
|
||||
|
||||
# v5.3.0
|
||||
- [changed] Use the new registerInternalLibrary API to register with FirebaseCore. (#2137)
|
||||
|
||||
# v5.2.0
|
||||
- [added] Add support of Game Center sign in (#2127).
|
||||
|
||||
# v5.1.0
|
||||
- [added] Add support of custom FDL domain link (#2121).
|
||||
|
||||
# v5.0.5
|
||||
- [changed] Restore SafariServices framework dependency (#2002).
|
||||
|
||||
# v5.0.4
|
||||
- [fixed] Fix analyzer issues (#1740).
|
||||
|
||||
# v5.0.3
|
||||
- [added] Add `FIRAuthErrorCodeMalformedJWT`, which is raised on JWT token parsing.
|
||||
failures during auth operations (#1436).
|
||||
- [changed] Migrate to use FirebaseAuthInterop interfaces to access FirebaseAuth (#1501).
|
||||
|
||||
# v5.0.2
|
||||
- [fixed] Fix an issue where JWT date timestamps weren't parsed correctly. (#1319)
|
||||
- [fixed] Fix an issue where anonymous accounts weren't correctly promoted to
|
||||
non-anonymous when linked with passwordless email auth accounts. (#1383)
|
||||
- [fixed] Fix an exception from using an invalidated NSURLSession. (#1261)
|
||||
- [fixed] Fix a data race issue caught by the sanitizer. (#1446)
|
||||
|
||||
# v5.0.1
|
||||
- [fixed] Restore 4.x level of support for extensions (#1357).
|
||||
|
||||
# v5.0.0
|
||||
- [added] Adds APIs for phone Auth testing to bypass the verification flow (#1192).
|
||||
- [feature] Changes the callback block signature for sign in and create user methods
|
||||
to provide an AuthDataResult that includes the user and user info (#1123, #1186).
|
||||
- [changed] Removes GoogleToolboxForMac dependency (#1175).
|
||||
- [removed] Removes miscellaneous deprecated APIs (#1188, #1200).
|
||||
|
||||
# v4.6.1
|
||||
- [fixed] Fixes crash which occurred when certain Firebase IDTokens were being parsed (#1076).
|
||||
|
||||
# v4.6.0
|
||||
- [added] Adds `getIDTokenResultWithCompletion:` and `getIDTokenResultForcingRefresh:completion:` APIs which
|
||||
call back with an AuthTokenResult object. The Auth token result object contains the ID token JWT string and other properties associated with the token including the decoded available payload claims (#1004).
|
||||
|
||||
- [added] Adds the `updateCurrentUser:completion:` API which sets the currentUser on the calling Auth instance to the provided user object (#1018).
|
||||
|
||||
- [added] Adds client-side validation to prevent setting `handleCodeInApp` to false when performing
|
||||
email-link authentication. If `handleCodeInApp` is set to false an invalid argument exception
|
||||
is thrown (#931).
|
||||
|
||||
- [added] Adds support for passing the deep link (which is embedded in the sign-in link sent via email) to the
|
||||
`signInWithEmail:link:completion:` and `isSignInWithEmailLink:` methods during an
|
||||
email/link sign-in flow (#1023).
|
||||
|
||||
# v4.5.0
|
||||
- [added] Adds new API which provides a way to determine the sign-in methods associated with an
|
||||
email address.
|
||||
- [added] Adds new API which allows authentication using only an email link (Passwordless Authentication
|
||||
with email link).
|
||||
|
||||
# v4.4.4
|
||||
- [fixed] Addresses CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF warnings that surface in newer versions of
|
||||
Xcode and CocoaPods.
|
||||
- [fixed] Improves FIRUser documentation with clear message explaining when Firebase Auth attempts to validate
|
||||
users and what happens when an invalidated user is detected (#694) .
|
||||
|
||||
# v4.4.3
|
||||
- [added] Adds an explicit dependency on CoreGraphics from Firebase Auth.
|
||||
|
||||
# v4.4.2
|
||||
- [fixed] Fixes bug where the FIRAuthResult object returned following a Phone Number authentication
|
||||
always contained a nil FIRAdditionalUserInfo object. Now the FIRAdditionalUserInfo object is
|
||||
never nil and its newUser field is populated correctly.
|
||||
|
||||
# v4.4.0
|
||||
- [fixed] Adds new APIs which return an AuthDataResult object after successfully creating an
|
||||
Email/Password user, signing in anonymously, signing in with Email/Password and signing
|
||||
in with Custom Token. The AuthDataResult object contains the new user and additional
|
||||
information pertaining to the new user.
|
||||
|
||||
# v4.3.2
|
||||
- [fixed] Improves error handling for the phone number sign-in reCAPTCHA flow.
|
||||
- [fixed] Improves error handling for phone number linking flow.
|
||||
- [fixed] Fixes issue where after linking an anonymous user to a phone number the user remained
|
||||
anonymous.
|
||||
|
||||
# v4.3.1
|
||||
- [changed] Internal clean up.
|
||||
|
||||
# v4.3.0
|
||||
- [added] Provides account creation and last sign-in dates as metadata to the user
|
||||
object.
|
||||
- [added] Returns more descriptive errors for some error cases of the phone number
|
||||
sign-in reCAPTCHA flow.
|
||||
- [fixed] Fixes an issue that invalid users were not automatically signed out earlier.
|
||||
- [fixed] Fixes an issue that ID token listeners were not fired in some cases.
|
||||
|
||||
# v4.2.1
|
||||
- [fixed] Fixes a threading issue in phone number auth that completion block was not
|
||||
executed on the main thread in some error cases.
|
||||
|
||||
# v4.2.0
|
||||
- [added] Adds new phone number verification API which makes use of an intelligent reCAPTCHA to verify the application.
|
||||
|
||||
# v4.1.1
|
||||
- [changed] Improves some method documentation in headers.
|
||||
|
||||
# v4.1.0
|
||||
- [added] Allows the app to handle continue URL natively, e.g., from password reset
|
||||
email.
|
||||
- [added] Allows the app to set language code, e.g., for sending password reset email.
|
||||
- [fixed] Fixes an issue that user's phone number did not persist on client.
|
||||
- [fixed] Fixes an issue that recover email action code type was reported as unknown.
|
||||
- [feature] Improves app start-up time by moving initialization off from the main
|
||||
thread.
|
||||
- [fixed] Better reports missing email error when creating a new password user.
|
||||
- [fixed] Changes console message logging levels to be more consistent with other
|
||||
Firebase products on the iOS platform.
|
||||
|
||||
# 2017-05-17 -- v4.0.0
|
||||
- [added] Adds Phone Number Authentication.
|
||||
- [added] Adds support for generic OAuth2 identity providers.
|
||||
- [added] Adds methods that return additional user data from identity providers if
|
||||
available when authenticating users.
|
||||
- [added] Improves session management by automatically refreshing tokens if possible
|
||||
and signing out users if the session is detected invalidated, for example,
|
||||
after the user changed password or deleted account from another device.
|
||||
- [fixed] Fixes an issue that reauthentication creates new user account if the user
|
||||
credential is valid but does not match the currently signed in user.
|
||||
- [fixed] Fixes an issue that the "password" provider is not immediately listed on the
|
||||
client side after adding a password to an account.
|
||||
- [changed] Changes factory methods to return non-null FIRAuth instances or raises an
|
||||
exception, instead of returning nullable instances.
|
||||
- [changed] Changes auth state change listener to only be triggered when the user changes.
|
||||
- [added] Adds a new listener which is triggered whenever the ID token is changed.
|
||||
- [changed] Switches ERROR_EMAIL_ALREADY_IN_USE to
|
||||
ERROR_ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL when the email used in the
|
||||
signInWithCredential: call is already in use by another account.
|
||||
- [deprecated] Deprecates FIREmailPasswordAuthProvider in favor of FIREmailAuthProvider.
|
||||
- [deprecated] Deprecates getTokenWithCompletion in favor of getIDTokenWithCompletion on
|
||||
FIRUser.
|
||||
- [fixed] Changes Swift API names to better align with Swift convention.
|
||||
|
||||
# 2017-02-06 -- v3.1.1
|
||||
- [added] Allows handling of additional errors when sending OOB action emails. The
|
||||
server can respond with the following new error messages:
|
||||
INVALID_MESSAGE_PAYLOAD,INVALID_SENDER and INVALID_RECIPIENT_EMAIL.
|
||||
- [fixed] Removes incorrect reference to FIRAuthErrorCodeCredentialTooOld in FIRUser.h.
|
||||
- [added] Provides additional error information from server if available.
|
||||
|
||||
# 2016-12-13 -- v3.1.0
|
||||
- [added] Adds FIRAuth methods that enable the app to follow up with user actions
|
||||
delivered by email, such as verifying email address or reset password.
|
||||
- [fixed] No longer applies the keychain workaround introduced in v3.0.5 on iOS 10.2
|
||||
simulator or above since the issue has been fixed.
|
||||
- [fixed] Fixes nullability compilation warnings when used in Swift.
|
||||
- [fixed] Better reports missing password error.
|
||||
|
||||
# 2016-10-24 -- v3.0.6
|
||||
- [changed] Switches to depend on open sourced GoogleToolboxForMac and GTMSessionFetcher.
|
||||
- [fixed] Improves logging of keychain error when initializing.
|
||||
|
||||
# 2016-09-14 -- v3.0.5
|
||||
- [fixed] Works around a keychain issue in iOS 10 simulator.
|
||||
- [fixed] Reports the correct error for invalid email when signing in with email and
|
||||
password.
|
||||
|
||||
# 2016-07-18 -- v3.0.4
|
||||
- [fixed] Fixes a race condition bug that could crash the app with an exception from
|
||||
NSURLSession on iOS 9.
|
||||
|
||||
# 2016-06-20 -- v3.0.3
|
||||
- [added] Adds documentation for all possible errors returned by each method.
|
||||
- [fixed] Improves error handling and messages for a variety of error conditions.
|
||||
- [fixed] Whether or not an user is considered anonymous is now consistent with other
|
||||
platforms.
|
||||
- [changed] A saved signed in user is now siloed between different Firebase projects
|
||||
within the same app.
|
||||
|
||||
# 2016-05-18 -- v3.0.2
|
||||
- Initial public release.
|
||||
Generated
+17
@@ -0,0 +1,17 @@
|
||||
# Firebase Auth for iOS
|
||||
|
||||
Firebase Auth enables apps to easily support multiple authentication options
|
||||
for their end users.
|
||||
|
||||
Please visit [our developer site](https://firebase.google.com/docs/auth/) for
|
||||
integration instructions, documentation, support information, and terms of
|
||||
service.
|
||||
|
||||
# Firebase Auth Development
|
||||
|
||||
Example/Auth contains a set of samples and tests that integrate with
|
||||
FirebaseAuth.
|
||||
|
||||
The unit tests run without any additional configuration along with the rest of
|
||||
Firebase. See [Tests/Sample/README.md](Tests/Sample/README.md) for
|
||||
information about setting up, running, and testing the samples.
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Public/FirebaseAuth/FIRActionCodeSettings.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation FIRActionCodeSettings
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_iOSBundleID = [NSBundle mainBundle].bundleIdentifier;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (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
|
||||
+2274
File diff suppressed because it is too large
Load Diff
@@ -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/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 "FirebaseAuth/Sources/Public/FirebaseAuth/FIRAdditionalUserInfo.h"
|
||||
#import "FirebaseAuth/Sources/Public/FirebaseAuth/FIROAuthCredential.h"
|
||||
#import "FirebaseAuth/Sources/Public/FirebaseAuth/FIRUser.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/Auth/FIRAuthDataResult_Internal.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation FIRAuthDataResult
|
||||
|
||||
/** @var kAdditionalUserInfoCodingKey
|
||||
@brief The key used to encode the additionalUserInfo property for NSSecureCoding.
|
||||
*/
|
||||
static NSString *const kAdditionalUserInfoCodingKey = @"additionalUserInfo";
|
||||
|
||||
/** @var kUserCodingKey
|
||||
@brief The key used to encode the user property for NSSecureCoding.
|
||||
*/
|
||||
static NSString *const kUserCodingKey = @"user";
|
||||
|
||||
/** @var kCredentialCodingKey
|
||||
@brief The key used to encode the credential for NSSecureCoding.
|
||||
*/
|
||||
static NSString *const kCredentialCodingKey = @"credential";
|
||||
|
||||
- (nullable instancetype)initWithUser:(FIRUser *)user
|
||||
additionalUserInfo:(nullable FIRAdditionalUserInfo *)additionalUserInfo {
|
||||
return [self initWithUser:user additionalUserInfo:additionalUserInfo credential:nil];
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithUser:(FIRUser *)user
|
||||
additionalUserInfo:(nullable FIRAdditionalUserInfo *)additionalUserInfo
|
||||
credential:(nullable FIROAuthCredential *)credential {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_additionalUserInfo = additionalUserInfo;
|
||||
_user = user;
|
||||
_credential = credential;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - NSSecureCoding
|
||||
|
||||
+ (BOOL)supportsSecureCoding {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder {
|
||||
FIRUser *user = [aDecoder decodeObjectOfClass:[FIRUser class] forKey:kUserCodingKey];
|
||||
FIRAdditionalUserInfo *additionalUserInfo =
|
||||
[aDecoder decodeObjectOfClass:[FIRAdditionalUserInfo class]
|
||||
forKey:kAdditionalUserInfoCodingKey];
|
||||
FIROAuthCredential *credential = [aDecoder decodeObjectOfClass:[FIROAuthCredential class]
|
||||
forKey:kCredentialCodingKey];
|
||||
return [self initWithUser:user additionalUserInfo:additionalUserInfo credential:credential];
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)aCoder {
|
||||
[aCoder encodeObject:_user forKey:kUserCodingKey];
|
||||
[aCoder encodeObject:_additionalUserInfo forKey:kAdditionalUserInfoCodingKey];
|
||||
[aCoder encodeObject:_credential forKey:kCredentialCodingKey];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Public/FirebaseAuth/FIRAuthDataResult.h"
|
||||
|
||||
@class FIROAuthCredential;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FIRAuthDataResult () <NSSecureCoding>
|
||||
|
||||
/** @fn initWithUser:additionalUserInfo:
|
||||
@brief Designated initializer.
|
||||
@param user The signed in user reference.
|
||||
@param additionalUserInfo The additional user info if available.
|
||||
*/
|
||||
- (nullable instancetype)initWithUser:(FIRUser *)user
|
||||
additionalUserInfo:(nullable FIRAdditionalUserInfo *)additionalUserInfo;
|
||||
|
||||
/** @fn initWithUser:additionalUserInfo:
|
||||
@brief Designated initializer.
|
||||
@param user The signed in user reference.
|
||||
@param additionalUserInfo The additional user info if available.
|
||||
@param credential The updated OAuth credential if available.
|
||||
*/
|
||||
- (nullable instancetype)initWithUser:(FIRUser *)user
|
||||
additionalUserInfo:(nullable FIRAdditionalUserInfo *)additionalUserInfo
|
||||
credential:(nullable FIROAuthCredential *)credential
|
||||
NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @typedef FIRAuthDispatcherImplBlock
|
||||
@brief The type of block which can be set as the implementation for @c
|
||||
dispatchAfterDelay:queue:callback: .
|
||||
|
||||
@param delay The delay in seconds after which the task will be scheduled to execute.
|
||||
@param queue The dispatch queue on which the task will be submitted.
|
||||
@param task The task (block) to be scheduled for future execution.
|
||||
*/
|
||||
typedef void (^FIRAuthDispatcherImplBlock)(NSTimeInterval delay,
|
||||
dispatch_queue_t queue,
|
||||
void (^task)(void));
|
||||
|
||||
/** @class FIRAuthDispatchAfter
|
||||
@brief A utility class used to facilitate scheduling tasks to be executed in the future.
|
||||
*/
|
||||
@interface FIRAuthDispatcher : NSObject
|
||||
|
||||
/** @property dispatchAfterImplementation
|
||||
@brief Allows custom implementation of dispatchAfterDelay:queue:callback:.
|
||||
@remarks Set to nil to restore default implementation.
|
||||
*/
|
||||
@property(nonatomic, nullable, copy) FIRAuthDispatcherImplBlock dispatchAfterImplementation;
|
||||
|
||||
/** @fn dispatchAfterDelay:queue:callback:
|
||||
@brief Schedules task in the future after a specified delay.
|
||||
|
||||
@param delay The delay in seconds after which the task will be scheduled to execute.
|
||||
@param queue The dispatch queue on which the task will be submitted.
|
||||
@param task The task (block) to be scheduled for future execution.
|
||||
*/
|
||||
- (void)dispatchAfterDelay:(NSTimeInterval)delay
|
||||
queue:(dispatch_queue_t)queue
|
||||
task:(void (^)(void))task;
|
||||
|
||||
/** @fn sharedInstance
|
||||
@brief Gets the shared instance of this class.
|
||||
@returns The shared instance of this clss
|
||||
*/
|
||||
+ (instancetype)sharedInstance;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Auth/FIRAuthDispatcher.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation FIRAuthDispatcher
|
||||
|
||||
@synthesize dispatchAfterImplementation = _dispatchAfterImplementation;
|
||||
|
||||
+ (instancetype)sharedInstance {
|
||||
static dispatch_once_t onceToken;
|
||||
static FIRAuthDispatcher *sharedInstance;
|
||||
dispatch_once(&onceToken, ^{
|
||||
sharedInstance = [[self alloc] init];
|
||||
});
|
||||
return sharedInstance;
|
||||
}
|
||||
|
||||
- (void)dispatchAfterDelay:(NSTimeInterval)delay
|
||||
queue:(dispatch_queue_t)queue
|
||||
task:(void (^)(void))task {
|
||||
if (_dispatchAfterImplementation) {
|
||||
_dispatchAfterImplementation(delay, queue, task);
|
||||
return;
|
||||
}
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delay * NSEC_PER_SEC), queue, task);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @fn FIRAuthGlobalWorkQueue
|
||||
@brief Retrieves the global serial work queue for Firebase Auth.
|
||||
@return The global serial dispatch queue.
|
||||
@remarks To ensure thread safety, all auth code must be executed in either this global work
|
||||
queue, or a serial queue that has its target queue set to this work queue. All public method
|
||||
implementations that may involve contested code shall dispatch to this work queue as the
|
||||
first thing they do.
|
||||
*/
|
||||
extern dispatch_queue_t FIRAuthGlobalWorkQueue(void);
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Auth/FIRAuthGlobalWorkQueue.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
dispatch_queue_t FIRAuthGlobalWorkQueue() {
|
||||
static dispatch_once_t once;
|
||||
static dispatch_queue_t queue;
|
||||
dispatch_once(&once, ^{
|
||||
queue = dispatch_queue_create("com.google.firebase.auth.globalWorkQueue", NULL);
|
||||
});
|
||||
return queue;
|
||||
}
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -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>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
@brief Indicates the type of operation performed for RPCs that support the operation
|
||||
parameter.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, FIRAuthOperationType) {
|
||||
/** Indicates that the operation type is uspecified.
|
||||
*/
|
||||
FIRAuthOperationTypeUnspecified = 0,
|
||||
|
||||
/** Indicates that the operation type is sign in or sign up.
|
||||
*/
|
||||
FIRAuthOperationTypeSignUpOrSignIn = 1,
|
||||
|
||||
/** Indicates that the operation type is reauthentication.
|
||||
*/
|
||||
FIRAuthOperationTypeReauth = 2,
|
||||
|
||||
/** Indicates that the operation type is update.
|
||||
*/
|
||||
FIRAuthOperationTypeUpdate = 3,
|
||||
|
||||
/** Indicates that the operation type is link.
|
||||
*/
|
||||
FIRAuthOperationTypeLink = 4,
|
||||
};
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @typedef FIRAuthSerialTaskCompletionBlock
|
||||
@brief The type of method a @c FIRAuthSerialTask must call when it is complete.
|
||||
*/
|
||||
typedef void (^FIRAuthSerialTaskCompletionBlock)(void);
|
||||
|
||||
/** @typedef FIRAuthSerialTask
|
||||
@brief Represents a unit of work submitted to a task queue.
|
||||
@param complete The task MUST call the complete method when done.
|
||||
*/
|
||||
typedef void (^FIRAuthSerialTask)(FIRAuthSerialTaskCompletionBlock complete);
|
||||
|
||||
/** @class FIRAuthSerialTaskQueue
|
||||
@brief An easy to use serial task queue which supports a callback-based completion notification
|
||||
system for easy asyncronous call chaining.
|
||||
*/
|
||||
@interface FIRAuthSerialTaskQueue : NSObject
|
||||
|
||||
/** @fn enqueueTask:
|
||||
@brief Enqueues a task for serial execution in the queue.
|
||||
@remarks The task MUST call the complete method when done. This method is thread-safe.
|
||||
The task block won't be executed concurrently with any other blocks in other task queues or
|
||||
the global work queue as returned by @c FIRAuthGlobalWorkQueue , but an uncompleted task
|
||||
(e.g. task block finished executation before complete method is called at a later time)
|
||||
does not affect other task queues or the global work queue.
|
||||
*/
|
||||
- (void)enqueueTask:(FIRAuthSerialTask)task;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Auth/FIRAuthSerialTaskQueue.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/Auth/FIRAuthGlobalWorkQueue.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation FIRAuthSerialTaskQueue {
|
||||
/** @var _dispatchQueue
|
||||
@brief The asyncronous dispatch queue into which tasks are enqueued and processed
|
||||
serially.
|
||||
*/
|
||||
dispatch_queue_t _dispatchQueue;
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_dispatchQueue = dispatch_queue_create("com.google.firebase.auth.serialTaskQueue", NULL);
|
||||
dispatch_set_target_queue(_dispatchQueue, FIRAuthGlobalWorkQueue());
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)enqueueTask:(FIRAuthSerialTask)task {
|
||||
// This dispatch queue will run tasks serially in FIFO order, as long as it's not suspended.
|
||||
dispatch_async(self->_dispatchQueue, ^{
|
||||
// But as soon as a task is started, stop other tasks from running until the task calls it's
|
||||
// completion handler, which allows the queue to resume processing of tasks. This allows the
|
||||
// task to perform other asyncronous actions on other dispatch queues and "get back to us" when
|
||||
// all of their sub-tasks are complete.
|
||||
dispatch_suspend(self->_dispatchQueue);
|
||||
task(^{
|
||||
dispatch_resume(self->_dispatchQueue);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2018 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 "FirebaseAuth/Sources/Public/FirebaseAuth/FIRAuthSettings.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation FIRAuthSettings
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_appVerificationDisabledForTesting = NO;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)copyWithZone:(NSZone *__unused _Nullable)zone {
|
||||
// Auth settings are mutable, so always return a copy.
|
||||
FIRAuthSettings *newSettings = [[FIRAuthSettings alloc] init];
|
||||
newSettings.appVerificationDisabledForTesting = self.isAppVerificationDisabledForTesting;
|
||||
return newSettings;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
* Copyright 2018 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 "FirebaseAuth/Sources/Auth/FIRAuthTokenResult_Internal.h"
|
||||
#import "FirebaseAuth/Sources/Utilities/FIRAuthErrorUtils.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @var kExpirationDateKey
|
||||
@brief The key used to encode the expirationDate property for NSSecureCoding.
|
||||
*/
|
||||
static NSString *const kExpirationDateKey = @"expiratinDate";
|
||||
|
||||
/** @var kTokenKey
|
||||
@brief The key used to encode the token property for NSSecureCoding.
|
||||
*/
|
||||
static NSString *const kTokenKey = @"token";
|
||||
|
||||
/** @var kAuthDateKey
|
||||
@brief The key used to encode the authDate property for NSSecureCoding.
|
||||
*/
|
||||
static NSString *const kAuthDateKey = @"authDate";
|
||||
|
||||
/** @var kIssuedDateKey
|
||||
@brief The key used to encode the issuedDate property for NSSecureCoding.
|
||||
*/
|
||||
static NSString *const kIssuedDateKey = @"issuedDate";
|
||||
|
||||
/** @var kSignInProviderKey
|
||||
@brief The key used to encode the signInProvider property for NSSecureCoding.
|
||||
*/
|
||||
static NSString *const kSignInProviderKey = @"signInProvider";
|
||||
|
||||
/** @var kSignInSecondFactorKey
|
||||
@brief The key used to encode the signInSecondFactor property for NSSecureCoding.
|
||||
*/
|
||||
static NSString *const kSignInSecondFactorKey = @"signInSecondFactor";
|
||||
|
||||
/** @var kClaimsKey
|
||||
@brief The key used to encode the claims property for NSSecureCoding.
|
||||
*/
|
||||
static NSString *const kClaimsKey = @"claims";
|
||||
|
||||
@implementation FIRAuthTokenResult
|
||||
|
||||
- (instancetype)initWithToken:(NSString *)token
|
||||
expirationDate:(NSDate *)expirationDate
|
||||
authDate:(NSDate *)authDate
|
||||
issuedAtDate:(NSDate *)issuedAtDate
|
||||
signInProvider:(NSString *)signInProvider
|
||||
signInSecondFactor:(NSString *)signInSecondFactor
|
||||
claims:(NSDictionary *)claims {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_token = token;
|
||||
_expirationDate = expirationDate;
|
||||
_authDate = authDate;
|
||||
_issuedAtDate = issuedAtDate;
|
||||
_signInProvider = signInProvider;
|
||||
_signInSecondFactor = signInSecondFactor;
|
||||
_claims = claims;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (nullable FIRAuthTokenResult *)tokenResultWithToken:(NSString *)token {
|
||||
NSArray *tokenStringArray = [token componentsSeparatedByString:@"."];
|
||||
|
||||
// The JWT should have three parts, though we only use the second in this method.
|
||||
if (tokenStringArray.count != 3) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
// The token payload is always the second index of the array.
|
||||
NSString *IDToken = tokenStringArray[1];
|
||||
|
||||
// Convert the base64URL encoded string to a base64 encoded string.
|
||||
// Replace "_" with "/"
|
||||
NSMutableString *tokenPayload = [[IDToken stringByReplacingOccurrencesOfString:@"_"
|
||||
withString:@"/"] mutableCopy];
|
||||
|
||||
// Replace "-" with "+"
|
||||
[tokenPayload replaceOccurrencesOfString:@"-"
|
||||
withString:@"+"
|
||||
options:kNilOptions
|
||||
range:NSMakeRange(0, tokenPayload.length)];
|
||||
|
||||
// Pad the token payload with "=" signs if the payload's length is not a multiple of 4.
|
||||
while ((tokenPayload.length % 4) != 0) {
|
||||
[tokenPayload appendFormat:@"="];
|
||||
}
|
||||
NSData *decodedTokenPayloadData =
|
||||
[[NSData alloc] initWithBase64EncodedString:tokenPayload
|
||||
options:NSDataBase64DecodingIgnoreUnknownCharacters];
|
||||
if (!decodedTokenPayloadData) {
|
||||
return nil;
|
||||
}
|
||||
NSError *jsonError = nil;
|
||||
NSJSONReadingOptions options = NSJSONReadingMutableContainers | NSJSONReadingAllowFragments;
|
||||
NSDictionary *tokenPayloadDictionary =
|
||||
[NSJSONSerialization JSONObjectWithData:decodedTokenPayloadData
|
||||
options:options
|
||||
error:&jsonError];
|
||||
if (jsonError != nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (!tokenPayloadDictionary) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
// These are dates since 00:00:00 January 1 1970, as described by the Terminology section in
|
||||
// the JWT spec. https://tools.ietf.org/html/rfc7519
|
||||
NSDate *expirationDate =
|
||||
[NSDate dateWithTimeIntervalSince1970:[tokenPayloadDictionary[@"exp"] doubleValue]];
|
||||
NSDate *authDate =
|
||||
[NSDate dateWithTimeIntervalSince1970:[tokenPayloadDictionary[@"auth_time"] doubleValue]];
|
||||
NSDate *issuedAtDate =
|
||||
[NSDate dateWithTimeIntervalSince1970:[tokenPayloadDictionary[@"iat"] doubleValue]];
|
||||
|
||||
NSDictionary *firebaseTokenPayloadDictionary = tokenPayloadDictionary[@"firebase"];
|
||||
NSString *signInProvider = firebaseTokenPayloadDictionary[@"sign_in_provider"];
|
||||
NSString *signInSecondFactor = firebaseTokenPayloadDictionary[@"sign_in_second_factor"];
|
||||
|
||||
FIRAuthTokenResult *tokenResult =
|
||||
[[FIRAuthTokenResult alloc] initWithToken:token
|
||||
expirationDate:expirationDate
|
||||
authDate:authDate
|
||||
issuedAtDate:issuedAtDate
|
||||
signInProvider:signInProvider
|
||||
signInSecondFactor:signInSecondFactor
|
||||
claims:tokenPayloadDictionary];
|
||||
return tokenResult;
|
||||
}
|
||||
|
||||
#pragma mark - NSSecureCoding
|
||||
|
||||
+ (BOOL)supportsSecureCoding {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder {
|
||||
NSString *token = [aDecoder decodeObjectOfClass:[NSDate class] forKey:kTokenKey];
|
||||
return [FIRAuthTokenResult tokenResultWithToken:token];
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)aCoder {
|
||||
[aCoder encodeObject:_token forKey:kTokenKey];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2018 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 "FirebaseAuth/Sources/Public/FirebaseAuth/FIRAuthTokenResult.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @extension FIRAuthAPNSTokenResult
|
||||
@brief An internal class used to expose internal methods of FIRAuthAPNSTokenResult.
|
||||
*/
|
||||
@interface FIRAuthTokenResult () <NSSecureCoding>
|
||||
|
||||
/** @fn tokenResultWithToken:
|
||||
@brief Parse a token string to a structured token.
|
||||
@param token The token string to parse.
|
||||
@return A structured token result.
|
||||
*/
|
||||
+ (nullable FIRAuthTokenResult *)tokenResultWithToken:(NSString *)token;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Public/FirebaseAuth/FIRAuth.h"
|
||||
#import "FirebaseCore/Sources/Private/FIRLogger.h"
|
||||
#import "Interop/Auth/Public/FIRAuthInterop.h"
|
||||
|
||||
@class FIRAuthRequestConfiguration;
|
||||
@class FIRAuthURLPresenter;
|
||||
|
||||
#if TARGET_OS_IOS
|
||||
@class FIRAuthAPNSTokenManager;
|
||||
@class FIRAuthAppCredentialManager;
|
||||
@class FIRAuthNotificationManager;
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FIRAuth () <FIRAuthInterop>
|
||||
|
||||
/** @property requestConfiguration
|
||||
@brief The configuration object comprising of paramters needed to make a request to Firebase
|
||||
Auth's backend.
|
||||
*/
|
||||
@property(nonatomic, copy, readonly) FIRAuthRequestConfiguration *requestConfiguration;
|
||||
|
||||
#if TARGET_OS_IOS
|
||||
|
||||
/** @property tokenManager
|
||||
@brief The manager for APNs tokens used by phone number auth.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly) FIRAuthAPNSTokenManager *tokenManager;
|
||||
|
||||
/** @property appCredentailManager
|
||||
@brief The manager for app credentials used by phone number auth.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly) FIRAuthAppCredentialManager *appCredentialManager;
|
||||
|
||||
/** @property notificationManager
|
||||
@brief The manager for remote notifications used by phone number auth.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly) FIRAuthNotificationManager *notificationManager;
|
||||
|
||||
#endif // TARGET_OS_IOS
|
||||
|
||||
/** @property authURLPresenter
|
||||
@brief An object that takes care of presenting URLs via the auth instance.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly) FIRAuthURLPresenter *authURLPresenter;
|
||||
|
||||
/** @fn initWithAPIKey:appName:
|
||||
@brief Designated initializer.
|
||||
@param APIKey The Google Developers Console API key for making requests from your app.
|
||||
@param appName The name property of the previously created @c FIRApp instance.
|
||||
*/
|
||||
- (nullable instancetype)initWithAPIKey:(NSString *)APIKey
|
||||
appName:(NSString *)appName NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
/** @fn getUserID
|
||||
@brief Gets the identifier of the current user, if any.
|
||||
@return The identifier of the current user, or nil if there is no current user.
|
||||
*/
|
||||
- (nullable NSString *)getUserID;
|
||||
|
||||
/** @fn updateKeychainWithUser:error:
|
||||
@brief Updates the keychain for the given user.
|
||||
@param user The user to be updated.
|
||||
@param error The error caused the method to fail if the method returns NO.
|
||||
@return Whether updating keychain has succeeded or not.
|
||||
@remarks Called by @c FIRUser when user info or token changes occur.
|
||||
*/
|
||||
- (BOOL)updateKeychainWithUser:(FIRUser *)user error:(NSError *_Nullable *_Nullable)error;
|
||||
|
||||
/** @fn internalSignInWithCredential:callback:
|
||||
@brief Convenience method for @c internalSignInAndRetrieveDataWithCredential:callback:
|
||||
This method doesn't return additional identity provider data.
|
||||
*/
|
||||
- (void)internalSignInWithCredential:(FIRAuthCredential *)credential
|
||||
callback:(FIRAuthResultCallback)callback;
|
||||
|
||||
/** @fn internalSignInAndRetrieveDataWithCredential:callback:
|
||||
@brief Asynchronously signs in Firebase with the given 3rd party credentials (e.g. a Facebook
|
||||
login Access Token, a Google ID Token/Access Token pair, etc.) and returns additional
|
||||
identity provider data.
|
||||
@param credential The credential supplied by the IdP.
|
||||
@param isReauthentication Indicates whether or not the current invocation originated from an
|
||||
attempt to reauthenticate.
|
||||
@param callback A block which is invoked when the sign in finishes (or is cancelled.) Invoked
|
||||
asynchronously on the auth global work queue in the future.
|
||||
@remarks This is the internal counterpart of this method, which uses a callback that does not
|
||||
update the current user.
|
||||
*/
|
||||
- (void)internalSignInAndRetrieveDataWithCredential:(FIRAuthCredential *)credential
|
||||
isReauthentication:(BOOL)isReauthentication
|
||||
callback:(nullable FIRAuthDataResultCallback)callback;
|
||||
|
||||
/** @fn signOutByForceWithUserID:error:
|
||||
@brief Signs out the current user.
|
||||
@param userID The ID of the user to force sign out.
|
||||
@param error An optional out parameter for error results.
|
||||
@return @YES when the sign out request was successful. @NO otherwise.
|
||||
*/
|
||||
- (BOOL)signOutByForceWithUserID:(NSString *)userID error:(NSError *_Nullable *_Nullable)error;
|
||||
|
||||
/** @fn completeSignInWithTokenService:callback:
|
||||
@brief Completes a sign-in flow once we have access and refresh tokens for the user.
|
||||
@param accessToken The STS access token.
|
||||
@param accessTokenExpirationDate The approximate expiration date of the access token.
|
||||
@param refreshToken The STS refresh token.
|
||||
@param anonymous Whether or not the user is anonymous.
|
||||
@param callback Called when the user has been signed in or when an error occurred. Invoked
|
||||
asynchronously on the global auth work queue in the future.
|
||||
*/
|
||||
- (void)completeSignInWithAccessToken:(nullable NSString *)accessToken
|
||||
accessTokenExpirationDate:(nullable NSDate *)accessTokenExpirationDate
|
||||
refreshToken:(nullable NSString *)refreshToken
|
||||
anonymous:(BOOL)anonymous
|
||||
callback:(FIRAuthResultCallback)callback;
|
||||
|
||||
/** @fn signInFlowAuthResultCallbackByDecoratingCallback:
|
||||
@brief Creates a FIRAuthResultCallback block which wraps another FIRAuthResultCallback; trying
|
||||
to update the current user before forwarding it's invocations along to a subject block
|
||||
@param callback Called when the user has been updated or when an error has occurred. Invoked
|
||||
asynchronously on the main thread in the future.
|
||||
@return Returns a block that updates the current user.
|
||||
@remarks Typically invoked as part of the complete sign-in flow. For any other uses please
|
||||
consider alternative ways of updating the current user.
|
||||
*/
|
||||
- (FIRAuthDataResultCallback)signInFlowAuthDataResultCallbackByDecoratingCallback:
|
||||
(nullable FIRAuthDataResultCallback)callback;
|
||||
|
||||
@end
|
||||
|
||||
/// Logger Service String
|
||||
|
||||
extern FIRLoggerService kFIRLoggerAuth;
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Public/FirebaseAuth/FIREmailAuthProvider.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/AuthProvider/Email/FIREmailPasswordAuthCredential.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation FIREmailAuthProvider
|
||||
|
||||
- (instancetype)init {
|
||||
@throw [NSException exceptionWithName:@"Attempt to call unavailable initializer."
|
||||
reason:@"This class is not meant to be initialized."
|
||||
userInfo:nil];
|
||||
}
|
||||
|
||||
+ (FIRAuthCredential *)credentialWithEmail:(NSString *)email password:(NSString *)password {
|
||||
return [[FIREmailPasswordAuthCredential alloc] initWithEmail:email password:password];
|
||||
}
|
||||
|
||||
+ (FIRAuthCredential *)credentialWithEmail:(NSString *)email link:(NSString *)link {
|
||||
return [[FIREmailPasswordAuthCredential alloc] initWithEmail:email link:link];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Generated
+61
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/AuthProvider/FIRAuthCredential_Internal.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @class FIREmailPasswordAuthCredential
|
||||
@brief Internal implementation of FIRAuthCredential for Email/Password credentials.
|
||||
*/
|
||||
@interface FIREmailPasswordAuthCredential : FIRAuthCredential <NSSecureCoding>
|
||||
|
||||
/** @property email
|
||||
@brief The user's email address.
|
||||
*/
|
||||
@property(nonatomic, readonly) NSString *email;
|
||||
|
||||
/** @property password
|
||||
@brief The user's password.
|
||||
*/
|
||||
@property(nonatomic, readonly) NSString *password;
|
||||
|
||||
/** @property link
|
||||
@brief The email sign-in link.
|
||||
*/
|
||||
@property(nonatomic, readonly) NSString *link;
|
||||
|
||||
/** @fn initWithEmail:password:
|
||||
@brief Designated initializer.
|
||||
@param email The user's email address.
|
||||
@param password The user's password.
|
||||
*/
|
||||
- (nullable instancetype)initWithEmail:(NSString *)email
|
||||
password:(NSString *)password NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
/** @fn initWithEmail:link:
|
||||
@brief Designated initializer.
|
||||
@param email The user's email address.
|
||||
@param link The email sign-in link.
|
||||
*/
|
||||
- (nullable instancetype)initWithEmail:(NSString *)email
|
||||
link:(NSString *)link NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Generated
+92
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/AuthProvider/Email/FIREmailPasswordAuthCredential.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/Public/FirebaseAuth/FIREmailAuthProvider.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/FIRVerifyAssertionRequest.h"
|
||||
#import "FirebaseAuth/Sources/Utilities/FIRAuthExceptionUtils.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FIREmailPasswordAuthCredential ()
|
||||
|
||||
- (nullable instancetype)initWithProvider:(NSString *)provider NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FIREmailPasswordAuthCredential
|
||||
|
||||
- (nullable instancetype)initWithProvider:(NSString *)provider {
|
||||
[FIRAuthExceptionUtils
|
||||
raiseMethodNotImplementedExceptionWithReason:@"Please call the designated initializer."];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithEmail:(NSString *)email password:(NSString *)password {
|
||||
self = [super initWithProvider:FIREmailAuthProviderID];
|
||||
if (self) {
|
||||
_email = [email copy];
|
||||
_password = [password copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithEmail:(NSString *)email link:(NSString *)link {
|
||||
self = [super initWithProvider:FIREmailAuthProviderID];
|
||||
if (self) {
|
||||
_email = [email copy];
|
||||
_link = [link copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)prepareVerifyAssertionRequest:(FIRVerifyAssertionRequest *)request {
|
||||
[FIRAuthExceptionUtils
|
||||
raiseMethodNotImplementedExceptionWithReason:
|
||||
@"Attempt to call prepareVerifyAssertionRequest: on a FIREmailPasswordAuthCredential."];
|
||||
}
|
||||
|
||||
#pragma mark - NSSecureCoding
|
||||
|
||||
+ (BOOL)supportsSecureCoding {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder {
|
||||
NSString *email = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"email"];
|
||||
NSString *password = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"password"];
|
||||
NSString *link = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"link"];
|
||||
if (email.length && password.length) {
|
||||
self = [self initWithEmail:email password:password];
|
||||
} else if (email.length && link.length) {
|
||||
self = [self initWithEmail:email link:link];
|
||||
} else {
|
||||
self = nil;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)aCoder {
|
||||
[aCoder encodeObject:self.email forKey:@"email"];
|
||||
[aCoder encodeObject:self.password forKey:@"password"];
|
||||
[aCoder encodeObject:self.link forKey:@"link"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/AuthProvider/FIRAuthCredential_Internal.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation FIRAuthCredential
|
||||
|
||||
- (instancetype)init {
|
||||
@throw [NSException exceptionWithName:@"Attempt to call unavailable initializer."
|
||||
reason:@"This class is an abstract base class. It's init method "
|
||||
"should not be called directly."
|
||||
userInfo:nil];
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithProvider:(NSString *)provider {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_provider = [provider copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)prepareVerifyAssertionRequest:(FIRVerifyAssertionRequest *)request {
|
||||
@throw [NSException exceptionWithName:@"Attempt to call virtual method."
|
||||
reason:@"This method must be overridden by a subclass."
|
||||
userInfo:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Public/FirebaseAuth/FIRAuthCredential.h"
|
||||
|
||||
@class FIRVerifyAssertionRequest;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FIRAuthCredential ()
|
||||
|
||||
/** @fn initWithProvider:
|
||||
@brief Designated initializer.
|
||||
@remarks This is the designated initializer for internal/friend subclasses.
|
||||
@param provider The provider name.
|
||||
*/
|
||||
- (nullable instancetype)initWithProvider:(NSString *)provider NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
/** @fn prepareVerifyAssertionRequest:
|
||||
@brief Called immediately before a request to the verifyAssertion endpoint is made. Implementers
|
||||
should update the passed request instance with their credentials.
|
||||
@param request The request to be updated with credentials.
|
||||
*/
|
||||
- (void)prepareVerifyAssertionRequest:(FIRVerifyAssertionRequest *)request;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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>
|
||||
|
||||
#pragma mark - Provider ID constants
|
||||
|
||||
// Declared 'extern' in FIRGoogleAuthProvider.h
|
||||
NSString *const FIRGoogleAuthProviderID = @"google.com";
|
||||
|
||||
// Declared 'extern' in FIRFacebookAuthProvider.h
|
||||
NSString *const FIRFacebookAuthProviderID = @"facebook.com";
|
||||
|
||||
// Declared 'extern' in FIREmailAuthProvider.h
|
||||
NSString *const FIREmailAuthProviderID = @"password";
|
||||
|
||||
// Declared 'extern' in FIRTwitterAuthProvider.h
|
||||
NSString *const FIRTwitterAuthProviderID = @"twitter.com";
|
||||
|
||||
// Declared 'extern' in FIRGitHubAuthProvider.h
|
||||
NSString *const FIRGitHubAuthProviderID = @"github.com";
|
||||
|
||||
// Declared 'extern' in FIRPhoneAuthProvider.h
|
||||
NSString *const FIRPhoneAuthProviderID = @"phone";
|
||||
|
||||
// Declared 'extern' in FIRGameCenterAuthProvider.h
|
||||
NSString *const FIRGameCenterAuthProviderID = @"gc.apple.com";
|
||||
|
||||
#pragma mark - sign-in methods constants
|
||||
|
||||
// Declared 'extern' in FIRGoogleAuthProvider.h
|
||||
NSString *const FIRGoogleAuthSignInMethod = @"google.com";
|
||||
|
||||
// Declared 'extern' in FIREmailAuthProvider.h
|
||||
NSString *const FIREmailPasswordAuthSignInMethod = @"password";
|
||||
|
||||
// Declared 'extern' in FIREmailAuthProvider.h
|
||||
NSString *const FIREmailLinkAuthSignInMethod = @"emailLink";
|
||||
|
||||
// Declared 'extern' in FIRTwitterAuthProvider.h
|
||||
NSString *const FIRTwitterAuthSignInMethod = @"twitter.com";
|
||||
|
||||
// Declared 'extern' in FIRFacebookAuthProvider.h
|
||||
NSString *const FIRFacebookAuthSignInMethod = @"facebook.com";
|
||||
|
||||
// Declared 'extern' in FIRGitHubAuthProvider.h
|
||||
NSString *const FIRGitHubAuthSignInMethod = @"github.com";
|
||||
|
||||
// Declared 'extern' in FIRPhoneAuthProvider.h
|
||||
NSString *const FIRPhoneAuthSignInMethod = @"phone";
|
||||
|
||||
// Declared 'extern' in FIRGameCenterAuthProvider.h
|
||||
NSString *const FIRGameCenterAuthSignInMethod = @"gc.apple.com";
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/AuthProvider/FIRAuthCredential_Internal.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @class FIRFacebookAuthCredential
|
||||
@brief Internal implementation of FIRAuthCredential for the Facebook IdP.
|
||||
*/
|
||||
@interface FIRFacebookAuthCredential : FIRAuthCredential <NSSecureCoding>
|
||||
|
||||
/** @fn initWithAccessToken:
|
||||
@brief Designated initializer.
|
||||
@param accessToken The Access Token obtained from Facebook.
|
||||
*/
|
||||
- (nullable instancetype)initWithAccessToken:(NSString *)accessToken NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/AuthProvider/Facebook/FIRFacebookAuthCredential.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/Public/FirebaseAuth/FIRFacebookAuthProvider.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/FIRVerifyAssertionRequest.h"
|
||||
#import "FirebaseAuth/Sources/Utilities/FIRAuthExceptionUtils.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FIRFacebookAuthCredential ()
|
||||
|
||||
- (nullable instancetype)initWithProvider:(NSString *)provider NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FIRFacebookAuthCredential {
|
||||
NSString *_accessToken;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithProvider:(NSString *)provider {
|
||||
[FIRAuthExceptionUtils
|
||||
raiseMethodNotImplementedExceptionWithReason:@"Please call the designated initializer."];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithAccessToken:(NSString *)accessToken {
|
||||
self = [super initWithProvider:FIRFacebookAuthProviderID];
|
||||
if (self) {
|
||||
_accessToken = [accessToken copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)prepareVerifyAssertionRequest:(FIRVerifyAssertionRequest *)request {
|
||||
request.providerAccessToken = _accessToken;
|
||||
}
|
||||
|
||||
#pragma mark - NSSecureCoding
|
||||
|
||||
+ (BOOL)supportsSecureCoding {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder {
|
||||
NSString *accessToken = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"accessToken"];
|
||||
self = [self initWithAccessToken:accessToken];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)aCoder {
|
||||
[aCoder encodeObject:_accessToken forKey:@"accessToken"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Public/FirebaseAuth/FIRFacebookAuthProvider.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/AuthProvider/Facebook/FIRFacebookAuthCredential.h"
|
||||
#import "FirebaseAuth/Sources/Utilities/FIRAuthExceptionUtils.h"
|
||||
|
||||
// FIRFacebookAuthProviderID is defined in FIRAuthProvider.m.
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation FIRFacebookAuthProvider
|
||||
|
||||
- (instancetype)init {
|
||||
[FIRAuthExceptionUtils
|
||||
raiseMethodNotImplementedExceptionWithReason:@"This class is not meant to be initialized."];
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (FIRAuthCredential *)credentialWithAccessToken:(NSString *)accessToken {
|
||||
return [[FIRFacebookAuthCredential alloc] initWithAccessToken:accessToken];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Generated
+80
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright 2018 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 "FirebaseAuth/Sources/Public/FirebaseAuth/FIRAuthCredential.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @class FIRGameCenterAuthCredential
|
||||
@brief Internal implementation of FIRAuthCredential for Game Center credentials.
|
||||
*/
|
||||
@interface FIRGameCenterAuthCredential : FIRAuthCredential <NSSecureCoding>
|
||||
|
||||
/** @property playerID
|
||||
@brief The ID of the Game Center local player.
|
||||
*/
|
||||
@property(nonatomic, readonly) NSString *playerID;
|
||||
|
||||
/** @property publicKeyURL
|
||||
@brief The URL for the public encryption key.
|
||||
*/
|
||||
@property(nonatomic, readonly) NSURL *publicKeyURL;
|
||||
|
||||
/** @property signature
|
||||
@brief The verification signature data generated.
|
||||
*/
|
||||
@property(nonatomic, readonly) NSData *signature;
|
||||
|
||||
/** @property salt
|
||||
@brief A random string used to compute the hash and keep it randomized.
|
||||
*/
|
||||
@property(nonatomic, readonly) NSData *salt;
|
||||
|
||||
/** @property timestamp
|
||||
@brief The date and time that the signature was created.
|
||||
*/
|
||||
@property(nonatomic, readonly) uint64_t timestamp;
|
||||
|
||||
/** @property displayName
|
||||
@brief The display name of the local Game Center player.
|
||||
*/
|
||||
@property(nonatomic, readonly) NSString *displayName;
|
||||
|
||||
/** @fn initWithPlayerID:publicKeyURL:signature:salt:timestamp:displayName:
|
||||
@brief Designated initializer.
|
||||
@param publicKeyURL The URL for the public encryption key.
|
||||
@param signature The verification signature generated.
|
||||
@param salt A random string used to compute the hash and keep it randomized.
|
||||
@param timestamp The date and time that the signature was created.
|
||||
@param displayName The display name of the Game Center player.
|
||||
*/
|
||||
- (nullable instancetype)initWithPlayerID:(NSString *)playerID
|
||||
publicKeyURL:(NSURL *)publicKeyURL
|
||||
signature:(NSData *)signature
|
||||
salt:(NSData *)salt
|
||||
timestamp:(uint64_t)timestamp
|
||||
displayName:(NSString *)displayName NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
/** @fn initWithProvider:
|
||||
@brief Initializer with a provider name.
|
||||
@param provider The provider name.
|
||||
*/
|
||||
- (nullable instancetype)initWithProvider:(NSString *)provider NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Generated
+92
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright 2018 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 "FirebaseAuth/Sources/AuthProvider/GameCenter/FIRGameCenterAuthCredential.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/Public/FirebaseAuth/FIRGameCenterAuthProvider.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/AuthProvider/FIRAuthCredential_Internal.h"
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/FIRVerifyAssertionRequest.h"
|
||||
#import "FirebaseAuth/Sources/Utilities/FIRAuthExceptionUtils.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation FIRGameCenterAuthCredential
|
||||
|
||||
- (nullable instancetype)initWithProvider:(NSString *)provider {
|
||||
[FIRAuthExceptionUtils
|
||||
raiseMethodNotImplementedExceptionWithReason:@"Please call the designated initializer."];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithPlayerID:(NSString *)playerID
|
||||
publicKeyURL:(NSURL *)publicKeyURL
|
||||
signature:(NSData *)signature
|
||||
salt:(NSData *)salt
|
||||
timestamp:(uint64_t)timestamp
|
||||
displayName:(NSString *)displayName {
|
||||
self = [super initWithProvider:FIRGameCenterAuthProviderID];
|
||||
if (self) {
|
||||
_playerID = [playerID copy];
|
||||
_publicKeyURL = [publicKeyURL copy];
|
||||
_signature = [signature copy];
|
||||
_salt = [salt copy];
|
||||
_timestamp = timestamp;
|
||||
_displayName = [displayName copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)prepareVerifyAssertionRequest:(FIRVerifyAssertionRequest *)request {
|
||||
[FIRAuthExceptionUtils
|
||||
raiseMethodNotImplementedExceptionWithReason:
|
||||
@"Attempt to call prepareVerifyAssertionRequest: on a FIRGameCenterAuthCredential."];
|
||||
}
|
||||
|
||||
#pragma mark - NSSecureCoding
|
||||
|
||||
+ (BOOL)supportsSecureCoding {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder {
|
||||
NSString *playerID = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"playerID"];
|
||||
NSURL *publicKeyURL = [aDecoder decodeObjectOfClass:[NSURL class] forKey:@"publicKeyURL"];
|
||||
NSData *signature = [aDecoder decodeObjectOfClass:[NSData class] forKey:@"signature"];
|
||||
NSData *salt = [aDecoder decodeObjectOfClass:[NSData class] forKey:@"salt"];
|
||||
NSNumber *timestamp = [aDecoder decodeObjectOfClass:[NSNumber class] forKey:@"timestamp"];
|
||||
NSString *displayName = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"displayName"];
|
||||
self = [self initWithPlayerID:playerID
|
||||
publicKeyURL:publicKeyURL
|
||||
signature:signature
|
||||
salt:salt
|
||||
timestamp:timestamp.unsignedLongLongValue
|
||||
displayName:displayName];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)aCoder {
|
||||
[aCoder encodeObject:self.playerID forKey:@"playerID"];
|
||||
[aCoder encodeObject:self.publicKeyURL forKey:@"publicKeyURL"];
|
||||
[aCoder encodeObject:self.signature forKey:@"signature"];
|
||||
[aCoder encodeObject:self.salt forKey:@"salt"];
|
||||
[aCoder encodeObject:[NSNumber numberWithUnsignedLongLong:self.timestamp] forKey:@"timestamp"];
|
||||
[aCoder encodeObject:self.displayName forKey:@"displayName"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Generated
+92
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright 2018 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 "FirebaseAuth/Sources/Public/FirebaseAuth/FIRGameCenterAuthProvider.h"
|
||||
#import <GameKit/GameKit.h>
|
||||
|
||||
#import "FirebaseAuth/Sources/AuthProvider/GameCenter/FIRGameCenterAuthCredential.h"
|
||||
#import "FirebaseAuth/Sources/Utilities/FIRAuthErrorUtils.h"
|
||||
#import "FirebaseAuth/Sources/Utilities/FIRAuthExceptionUtils.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation FIRGameCenterAuthProvider
|
||||
|
||||
- (instancetype)init {
|
||||
[FIRAuthExceptionUtils
|
||||
raiseMethodNotImplementedExceptionWithReason:@"This class is not meant to be initialized."];
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (void)getCredentialWithCompletion:(FIRGameCenterCredentialCallback)completion {
|
||||
/**
|
||||
Linking GameKit.framework without using it on macOS results in App Store rejection.
|
||||
Thus we don't link GameKit.framework to our SDK directly. `optionalLocalPlayer` is used for
|
||||
checking whether the APP that consuming our SDK has linked GameKit.framework. If not, a
|
||||
`GameKitNotLinkedError` will be raised.
|
||||
**/
|
||||
GKLocalPlayer *_Nullable optionalLocalPlayer = [[NSClassFromString(@"GKLocalPlayer") alloc] init];
|
||||
|
||||
if (!optionalLocalPlayer) {
|
||||
if (completion) {
|
||||
completion(nil, [FIRAuthErrorUtils gameKitNotLinkedError]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
__weak GKLocalPlayer *localPlayer = [[optionalLocalPlayer class] localPlayer];
|
||||
if (!localPlayer.isAuthenticated) {
|
||||
if (completion) {
|
||||
completion(nil, [FIRAuthErrorUtils localPlayerNotAuthenticatedError]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
[localPlayer generateIdentityVerificationSignatureWithCompletionHandler:^(
|
||||
NSURL *publicKeyURL, NSData *signature, NSData *salt, uint64_t timestamp,
|
||||
NSError *error) {
|
||||
if (error) {
|
||||
if (completion) {
|
||||
completion(nil, error);
|
||||
}
|
||||
} else {
|
||||
if (completion) {
|
||||
/**
|
||||
@c `localPlayer.alias` is actually the displayname needed, instead of
|
||||
`localPlayer.displayname`. For more information, check
|
||||
https://developer.apple.com/documentation/gamekit/gkplayer
|
||||
**/
|
||||
NSString *displayName = localPlayer.alias;
|
||||
// iOS 13 deprecation
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
FIRGameCenterAuthCredential *credential =
|
||||
[[FIRGameCenterAuthCredential alloc] initWithPlayerID:localPlayer.playerID
|
||||
publicKeyURL:publicKeyURL
|
||||
signature:signature
|
||||
salt:salt
|
||||
timestamp:timestamp
|
||||
displayName:displayName];
|
||||
#pragma clang diagnostic pop
|
||||
completion(credential, nil);
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/AuthProvider/FIRAuthCredential_Internal.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @class FIRGitHubAuthCredential
|
||||
@brief Internal implementation of FIRAuthCredential for GitHub credentials.
|
||||
*/
|
||||
@interface FIRGitHubAuthCredential : FIRAuthCredential <NSSecureCoding>
|
||||
|
||||
/** @property token
|
||||
@brief The GitHub OAuth access token.
|
||||
*/
|
||||
@property(nonatomic, readonly) NSString *token;
|
||||
|
||||
/** @fn initWithToken:
|
||||
@brief Designated initializer.
|
||||
@param token The GitHub OAuth access token.
|
||||
*/
|
||||
- (nullable instancetype)initWithToken:(NSString *)token NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/AuthProvider/GitHub/FIRGitHubAuthCredential.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/Public/FirebaseAuth/FIRGitHubAuthProvider.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/FIRVerifyAssertionRequest.h"
|
||||
#import "FirebaseAuth/Sources/Utilities/FIRAuthExceptionUtils.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FIRGitHubAuthCredential ()
|
||||
|
||||
- (nullable instancetype)initWithProvider:(NSString *)provider NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FIRGitHubAuthCredential
|
||||
|
||||
- (nullable instancetype)initWithProvider:(NSString *)provider {
|
||||
[FIRAuthExceptionUtils
|
||||
raiseMethodNotImplementedExceptionWithReason:@"Please call the designated initializer."];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithToken:(NSString *)token {
|
||||
self = [super initWithProvider:FIRGitHubAuthProviderID];
|
||||
if (self) {
|
||||
_token = [token copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)prepareVerifyAssertionRequest:(FIRVerifyAssertionRequest *)request {
|
||||
request.providerAccessToken = _token;
|
||||
}
|
||||
|
||||
#pragma mark - NSSecureCoding
|
||||
|
||||
+ (BOOL)supportsSecureCoding {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder {
|
||||
NSString *token = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"token"];
|
||||
self = [self initWithToken:token];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)aCoder {
|
||||
[aCoder encodeObject:self.token forKey:@"token"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Public/FirebaseAuth/FIRGitHubAuthProvider.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/AuthProvider/GitHub/FIRGitHubAuthCredential.h"
|
||||
#import "FirebaseAuth/Sources/Utilities/FIRAuthExceptionUtils.h"
|
||||
|
||||
// FIRGitHubAuthProviderID is defined in FIRAuthProvider.m.
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation FIRGitHubAuthProvider
|
||||
|
||||
- (instancetype)init {
|
||||
[FIRAuthExceptionUtils
|
||||
raiseMethodNotImplementedExceptionWithReason:@"This class is not meant to be initialized."];
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (FIRAuthCredential *)credentialWithToken:(NSString *)token {
|
||||
return [[FIRGitHubAuthCredential alloc] initWithToken:token];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/AuthProvider/FIRAuthCredential_Internal.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @class FIRGoogleAuthCredential
|
||||
@brief Internal implementation of FIRAuthCredential for the Google IdP.
|
||||
*/
|
||||
@interface FIRGoogleAuthCredential : FIRAuthCredential <NSSecureCoding>
|
||||
|
||||
/** @fn initWithIDToken:accessToken:
|
||||
@brief Designated initializer.
|
||||
@param IDToken The ID Token obtained from Google.
|
||||
@param accessToken The Access Token obtained from Google.
|
||||
*/
|
||||
- (nullable instancetype)initWithIDToken:(NSString *)IDToken
|
||||
accessToken:(NSString *)accessToken NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/AuthProvider/Google/FIRGoogleAuthCredential.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/Public/FirebaseAuth/FIRGoogleAuthProvider.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/FIRVerifyAssertionRequest.h"
|
||||
#import "FirebaseAuth/Sources/Utilities/FIRAuthExceptionUtils.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FIRGoogleAuthCredential ()
|
||||
|
||||
- (nullable instancetype)initWithProvider:(NSString *)provider NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FIRGoogleAuthCredential {
|
||||
NSString *_IDToken;
|
||||
NSString *_accessToken;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithProvider:(NSString *)provider {
|
||||
[FIRAuthExceptionUtils
|
||||
raiseMethodNotImplementedExceptionWithReason:@"Please call the designated initializer."];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithIDToken:(NSString *)IDToken accessToken:(NSString *)accessToken {
|
||||
self = [super initWithProvider:FIRGoogleAuthProviderID];
|
||||
if (self) {
|
||||
_IDToken = [IDToken copy];
|
||||
_accessToken = [accessToken copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)prepareVerifyAssertionRequest:(FIRVerifyAssertionRequest *)request {
|
||||
request.providerIDToken = _IDToken;
|
||||
request.providerAccessToken = _accessToken;
|
||||
}
|
||||
|
||||
#pragma mark - NSSecureCoding
|
||||
|
||||
+ (BOOL)supportsSecureCoding {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder {
|
||||
NSString *IDToken = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"IDToken"];
|
||||
NSString *accessToken = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"accessToken"];
|
||||
self = [self initWithIDToken:IDToken accessToken:accessToken];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)aCoder {
|
||||
[aCoder encodeObject:_IDToken forKey:@"IDToken"];
|
||||
[aCoder encodeObject:_accessToken forKey:@"accessToken"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Public/FirebaseAuth/FIRGoogleAuthProvider.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/AuthProvider/Google/FIRGoogleAuthCredential.h"
|
||||
#import "FirebaseAuth/Sources/Utilities/FIRAuthExceptionUtils.h"
|
||||
|
||||
// FIRGoogleAuthProviderID is defined in FIRAuthProvider.m.
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation FIRGoogleAuthProvider
|
||||
|
||||
- (instancetype)init {
|
||||
[FIRAuthExceptionUtils
|
||||
raiseMethodNotImplementedExceptionWithReason:@"This class is not meant to be initialized."];
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (FIRAuthCredential *)credentialWithIDToken:(NSString *)IDToken
|
||||
accessToken:(NSString *)accessToken {
|
||||
return [[FIRGoogleAuthCredential alloc] initWithIDToken:IDToken accessToken:accessToken];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Public/FirebaseAuth/FIROAuthCredential.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/AuthProvider/FIRAuthCredential_Internal.h"
|
||||
#import "FirebaseAuth/Sources/AuthProvider/OAuth/FIROAuthCredential_Internal.h"
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/FIRVerifyAssertionRequest.h"
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/FIRVerifyAssertionResponse.h"
|
||||
#import "FirebaseAuth/Sources/Utilities/FIRAuthExceptionUtils.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FIROAuthCredential ()
|
||||
|
||||
@property(nonatomic, nullable) NSString *rawNonce;
|
||||
|
||||
- (nullable instancetype)initWithProvider:(NSString *)provider NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FIROAuthCredential
|
||||
|
||||
- (nullable instancetype)initWithProvider:(NSString *)provider {
|
||||
[FIRAuthExceptionUtils
|
||||
raiseMethodNotImplementedExceptionWithReason:@"Please call the designated initializer."];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (instancetype)initWithProviderID:(NSString *)providerID
|
||||
IDToken:(nullable NSString *)IDToken
|
||||
rawNonce:(nullable NSString *)rawNonce
|
||||
accessToken:(nullable NSString *)accessToken
|
||||
secret:(nullable NSString *)secret
|
||||
pendingToken:(nullable NSString *)pendingToken {
|
||||
self = [super initWithProvider:providerID];
|
||||
if (self) {
|
||||
_IDToken = IDToken;
|
||||
_rawNonce = rawNonce;
|
||||
_accessToken = accessToken;
|
||||
_pendingToken = pendingToken;
|
||||
_secret = secret;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithProviderID:(NSString *)providerID
|
||||
sessionID:(NSString *)sessionID
|
||||
OAuthResponseURLString:(NSString *)OAuthResponseURLString {
|
||||
self = [self initWithProviderID:providerID
|
||||
IDToken:nil
|
||||
rawNonce:nil
|
||||
accessToken:nil
|
||||
secret:nil
|
||||
pendingToken:nil];
|
||||
if (self) {
|
||||
_OAuthResponseURLString = OAuthResponseURLString;
|
||||
_sessionID = sessionID;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithVerifyAssertionResponse:(FIRVerifyAssertionResponse *)response {
|
||||
if (response.oauthIDToken.length || response.oauthAccessToken.length ||
|
||||
response.oauthSecretToken.length) {
|
||||
return [self initWithProviderID:response.providerID
|
||||
IDToken:response.oauthIDToken
|
||||
rawNonce:nil
|
||||
accessToken:response.oauthAccessToken
|
||||
secret:response.oauthSecretToken
|
||||
pendingToken:response.pendingToken];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)prepareVerifyAssertionRequest:(FIRVerifyAssertionRequest *)request {
|
||||
request.providerIDToken = _IDToken;
|
||||
request.providerRawNonce = _rawNonce;
|
||||
request.providerAccessToken = _accessToken;
|
||||
request.requestURI = _OAuthResponseURLString;
|
||||
request.sessionID = _sessionID;
|
||||
request.providerOAuthTokenSecret = _secret;
|
||||
request.pendingToken = _pendingToken;
|
||||
}
|
||||
|
||||
#pragma mark - NSSecureCoding
|
||||
|
||||
+ (BOOL)supportsSecureCoding {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder {
|
||||
NSString *IDToken = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"IDToken"];
|
||||
NSString *rawNonce = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"rawNonce"];
|
||||
NSString *accessToken = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"accessToken"];
|
||||
NSString *pendingToken = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"pendingToken"];
|
||||
NSString *secret = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"secret"];
|
||||
self = [self initWithProviderID:self.provider
|
||||
IDToken:IDToken
|
||||
rawNonce:rawNonce
|
||||
accessToken:accessToken
|
||||
secret:secret
|
||||
pendingToken:pendingToken];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)aCoder {
|
||||
[aCoder encodeObject:self.IDToken forKey:@"IDToken"];
|
||||
[aCoder encodeObject:self.rawNonce forKey:@"rawNonce"];
|
||||
[aCoder encodeObject:self.accessToken forKey:@"accessToken"];
|
||||
[aCoder encodeObject:self.pendingToken forKey:@"pendingToken"];
|
||||
[aCoder encodeObject:self.secret forKey:@"secret"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Public/FirebaseAuth/FIROAuthCredential.h"
|
||||
|
||||
@class FIRVerifyAssertionResponse;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @extension FIROAuthCredential
|
||||
@brief Internal implementation of FIRAuthCredential for generic credentials.
|
||||
*/
|
||||
@interface FIROAuthCredential ()
|
||||
|
||||
/** @property OAuthResponseURLString
|
||||
@brief A string representation of the response URL corresponding to this OAuthCredential.
|
||||
*/
|
||||
@property(nonatomic, readonly, nullable) NSString *OAuthResponseURLString;
|
||||
|
||||
/** @property sessionID
|
||||
@brief The session ID used when completing the headful-lite flow.
|
||||
*/
|
||||
@property(nonatomic, readonly, nullable) NSString *sessionID;
|
||||
|
||||
/** @property pendingToken
|
||||
@brief The pending token used when completing the headful-lite flow.
|
||||
*/
|
||||
@property(nonatomic, readonly, nullable) NSString *pendingToken;
|
||||
|
||||
/** @fn initWithProviderId:IDToken:accessToken:secret:pendingToken
|
||||
@brief Designated initializer.
|
||||
@param providerID The provider ID associated with the credential being created.
|
||||
@param IDToken The ID Token associated with the credential being created.
|
||||
@param rawNonce The raw nonce associated with the Auth credential being created.
|
||||
@param accessToken The access token associated with the credential being created.
|
||||
@param secret The secret associated with the credential being created.
|
||||
@param pendingToken The pending token associated with the credential being created.
|
||||
*/
|
||||
- (instancetype)initWithProviderID:(NSString *)providerID
|
||||
IDToken:(nullable NSString *)IDToken
|
||||
rawNonce:(nullable NSString *)rawNonce
|
||||
accessToken:(nullable NSString *)accessToken
|
||||
secret:(nullable NSString *)secret
|
||||
pendingToken:(nullable NSString *)pendingToken NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
/** @fn initWithProviderId:sessionID:OAuthResponseURLString:
|
||||
@brief Intitializer which takes a sessionID and an OAuthResponseURLString.
|
||||
@param providerID The provider ID associated with the credential being created.
|
||||
@param sessionID The session ID used when completing the headful-lite flow.
|
||||
@param OAuthResponseURLString The error that occurred if any.
|
||||
*/
|
||||
- (instancetype)initWithProviderID:(NSString *)providerID
|
||||
sessionID:(NSString *)sessionID
|
||||
OAuthResponseURLString:(NSString *)OAuthResponseURLString;
|
||||
|
||||
/** @fn initWithVerifyAssertionResponse
|
||||
@brief Intitializer which takes an verifyAssertion response.
|
||||
@param response The verifyAssertion Response to create the credential instance.
|
||||
*/
|
||||
- (nullable instancetype)initWithVerifyAssertionResponse:(FIRVerifyAssertionResponse *)response;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+445
@@ -0,0 +1,445 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Public/FirebaseAuth/FIROAuthProvider.h"
|
||||
#include <CommonCrypto/CommonCrypto.h>
|
||||
#import "FirebaseAuth/Sources/Public/FirebaseAuth/FIRFacebookAuthProvider.h"
|
||||
#import "FirebaseAuth/Sources/Public/FirebaseAuth/FIROAuthCredential.h"
|
||||
#import "FirebaseCore/Sources/Private/FirebaseCoreInternal.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/Auth/FIRAuthGlobalWorkQueue.h"
|
||||
#import "FirebaseAuth/Sources/Auth/FIRAuth_Internal.h"
|
||||
#import "FirebaseAuth/Sources/AuthProvider/OAuth/FIROAuthCredential_Internal.h"
|
||||
#import "FirebaseAuth/Sources/Backend/FIRAuthBackend.h"
|
||||
#import "FirebaseAuth/Sources/Backend/FIRAuthRequestConfiguration.h"
|
||||
#import "FirebaseAuth/Sources/Utilities/FIRAuthErrorUtils.h"
|
||||
#import "FirebaseAuth/Sources/Utilities/FIRAuthWebUtils.h"
|
||||
|
||||
#if TARGET_OS_IOS
|
||||
#import "FirebaseAuth/Sources/Utilities/FIRAuthURLPresenter.h"
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @typedef FIRHeadfulLiteURLCallBack
|
||||
@brief The callback invoked at the end of the flow to fetch a headful-lite URL.
|
||||
@param headfulLiteURL The headful lite URL.
|
||||
@param error The error that occurred while fetching the headful-lite, if any.
|
||||
*/
|
||||
typedef void (^FIRHeadfulLiteURLCallBack)(NSURL *_Nullable headfulLiteURL,
|
||||
NSError *_Nullable error);
|
||||
|
||||
/** @var kHeadfulLiteURLStringFormat
|
||||
@brief The format of the URL used to open the headful lite page during sign-in.
|
||||
*/
|
||||
NSString *const kHeadfulLiteURLStringFormat = @"https://%@/__/auth/handler?%@";
|
||||
|
||||
/** @var kHeadfulLiteEmulatorURLStringFormat
|
||||
@brief The format of the URL used to open the emulated headful lite page during sign-in.
|
||||
*/
|
||||
NSString *const kHeadfulLiteEmulatorURLStringFormat = @"http://%@/emulator/auth/handler?%@";
|
||||
|
||||
/** @var kauthTypeSignInWithRedirect
|
||||
@brief The auth type to be specified in the sign-in request with redirect request and response.
|
||||
*/
|
||||
static NSString *const kAuthTypeSignInWithRedirect = @"signInWithRedirect";
|
||||
|
||||
/** @var kCustomUrlSchemePrefix
|
||||
@brief The prefix to append to the Firebase app ID custom callback scheme..
|
||||
*/
|
||||
static NSString *const kCustomUrlSchemePrefix = @"app-";
|
||||
|
||||
@implementation FIROAuthProvider {
|
||||
/** @var _auth
|
||||
@brief The auth instance used for launching the URL presenter.
|
||||
*/
|
||||
FIRAuth *_auth;
|
||||
|
||||
/** @var _callbackScheme
|
||||
@brief The callback URL scheme used for headful-lite sign-in.
|
||||
*/
|
||||
NSString *_callbackScheme;
|
||||
|
||||
/** @var _usingClientIDScheme
|
||||
@brief True if the reverse client ID is registered as a custom URL scheme, and false
|
||||
otherwise.
|
||||
*/
|
||||
BOOL _usingClientIDScheme;
|
||||
}
|
||||
|
||||
+ (FIROAuthCredential *)credentialWithProviderID:(NSString *)providerID
|
||||
IDToken:(NSString *)IDToken
|
||||
accessToken:(nullable NSString *)accessToken {
|
||||
return [[FIROAuthCredential alloc] initWithProviderID:providerID
|
||||
IDToken:IDToken
|
||||
rawNonce:nil
|
||||
accessToken:accessToken
|
||||
secret:nil
|
||||
pendingToken:nil];
|
||||
}
|
||||
|
||||
+ (FIROAuthCredential *)credentialWithProviderID:(NSString *)providerID
|
||||
accessToken:(NSString *)accessToken {
|
||||
return [[FIROAuthCredential alloc] initWithProviderID:providerID
|
||||
IDToken:nil
|
||||
rawNonce:nil
|
||||
accessToken:accessToken
|
||||
secret:nil
|
||||
pendingToken:nil];
|
||||
}
|
||||
|
||||
+ (FIROAuthCredential *)credentialWithProviderID:(NSString *)providerID
|
||||
IDToken:(NSString *)IDToken
|
||||
rawNonce:(nullable NSString *)rawNonce
|
||||
accessToken:(nullable NSString *)accessToken {
|
||||
return [[FIROAuthCredential alloc] initWithProviderID:providerID
|
||||
IDToken:IDToken
|
||||
rawNonce:rawNonce
|
||||
accessToken:accessToken
|
||||
secret:nil
|
||||
pendingToken:nil];
|
||||
}
|
||||
|
||||
+ (FIROAuthCredential *)credentialWithProviderID:(NSString *)providerID
|
||||
IDToken:(NSString *)IDToken
|
||||
rawNonce:(nullable NSString *)rawNonce {
|
||||
return [[FIROAuthCredential alloc] initWithProviderID:providerID
|
||||
IDToken:IDToken
|
||||
rawNonce:rawNonce
|
||||
accessToken:nil
|
||||
secret:nil
|
||||
pendingToken:nil];
|
||||
}
|
||||
|
||||
+ (instancetype)providerWithProviderID:(NSString *)providerID {
|
||||
return [[self alloc] initWithProviderID:providerID auth:[FIRAuth auth]];
|
||||
}
|
||||
|
||||
+ (instancetype)providerWithProviderID:(NSString *)providerID auth:(FIRAuth *)auth {
|
||||
return [[self alloc] initWithProviderID:providerID auth:auth];
|
||||
}
|
||||
|
||||
#if TARGET_OS_IOS
|
||||
- (void)getCredentialWithUIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
|
||||
completion:(nullable FIRAuthCredentialCallback)completion {
|
||||
if (![FIRAuthWebUtils isCallbackSchemeRegisteredForCustomURLScheme:self->_callbackScheme]) {
|
||||
[NSException raise:NSInternalInconsistencyException
|
||||
format:@"Please register custom URL scheme '%@' in the app's Info.plist file.",
|
||||
self->_callbackScheme];
|
||||
}
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
__weak FIRAuth *weakAuth = _auth;
|
||||
__weak NSString *weakProviderID = _providerID;
|
||||
dispatch_async(FIRAuthGlobalWorkQueue(), ^{
|
||||
FIRAuthCredentialCallback callbackOnMainThread =
|
||||
^(FIRAuthCredential *_Nullable credential, NSError *_Nullable error) {
|
||||
if (completion) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
completion(credential, error);
|
||||
});
|
||||
}
|
||||
};
|
||||
NSString *eventID = [FIRAuthWebUtils randomStringWithLength:10];
|
||||
NSString *sessionID = [FIRAuthWebUtils randomStringWithLength:10];
|
||||
__strong __typeof__(self) strongSelf = weakSelf;
|
||||
[strongSelf
|
||||
getHeadFulLiteURLWithEventID:eventID
|
||||
sessionID:sessionID
|
||||
completion:^(NSURL *_Nullable headfulLiteURL, NSError *_Nullable error) {
|
||||
if (error) {
|
||||
callbackOnMainThread(nil, error);
|
||||
return;
|
||||
}
|
||||
FIRAuthURLCallbackMatcher callbackMatcher =
|
||||
^BOOL(NSURL *_Nullable callbackURL) {
|
||||
return [FIRAuthWebUtils
|
||||
isExpectedCallbackURL:callbackURL
|
||||
eventID:eventID
|
||||
authType:kAuthTypeSignInWithRedirect
|
||||
callbackScheme:strongSelf->_callbackScheme];
|
||||
};
|
||||
__strong FIRAuth *strongAuth = weakAuth;
|
||||
[strongAuth.authURLPresenter
|
||||
presentURL:headfulLiteURL
|
||||
UIDelegate:UIDelegate
|
||||
callbackMatcher:callbackMatcher
|
||||
completion:^(NSURL *_Nullable callbackURL,
|
||||
NSError *_Nullable error) {
|
||||
if (error) {
|
||||
callbackOnMainThread(nil, error);
|
||||
return;
|
||||
}
|
||||
NSString *OAuthResponseURLString =
|
||||
[strongSelf OAuthResponseForURL:callbackURL
|
||||
error:&error];
|
||||
if (error) {
|
||||
callbackOnMainThread(nil, error);
|
||||
return;
|
||||
}
|
||||
__strong NSString *strongProviderID = weakProviderID;
|
||||
FIROAuthCredential *credential = [[FIROAuthCredential alloc]
|
||||
initWithProviderID:strongProviderID
|
||||
sessionID:sessionID
|
||||
OAuthResponseURLString:OAuthResponseURLString];
|
||||
callbackOnMainThread(credential, nil);
|
||||
}];
|
||||
}];
|
||||
});
|
||||
}
|
||||
#endif // TARGET_OS_IOS
|
||||
|
||||
#pragma mark - Internal Methods
|
||||
|
||||
/** @fn initWithProviderID:auth:
|
||||
@brief returns an instance of @c FIROAuthProvider associated with the provided auth instance.
|
||||
@param auth The Auth instance to be associated with the OAuthProvider instance.
|
||||
@return An Instance of @c FIROAuthProvider.
|
||||
*/
|
||||
- (nullable instancetype)initWithProviderID:(NSString *)providerID auth:(FIRAuth *)auth {
|
||||
if (!auth.requestConfiguration.emulatorHostAndPort) {
|
||||
NSAssert(![providerID isEqual:FIRFacebookAuthProviderID],
|
||||
@"Sign in with Facebook is not supported via generic IDP; the Facebook TOS "
|
||||
"dictate that you must use the Facebook iOS SDK for Facebook login.");
|
||||
NSAssert(![providerID isEqual:@"apple.com"],
|
||||
@"Sign in with Apple is not supported via generic IDP; You must use the Apple iOS SDK"
|
||||
" for Sign in with Apple.");
|
||||
}
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_auth = auth;
|
||||
_providerID = providerID;
|
||||
if (_auth.app.options.clientID) {
|
||||
NSString *reverseClientIDScheme =
|
||||
[[[_auth.app.options.clientID componentsSeparatedByString:@"."]
|
||||
reverseObjectEnumerator].allObjects componentsJoinedByString:@"."];
|
||||
if ([FIRAuthWebUtils isCallbackSchemeRegisteredForCustomURLScheme:reverseClientIDScheme]) {
|
||||
_callbackScheme = reverseClientIDScheme;
|
||||
_usingClientIDScheme = YES;
|
||||
}
|
||||
}
|
||||
|
||||
if (!_usingClientIDScheme) {
|
||||
_callbackScheme = [kCustomUrlSchemePrefix
|
||||
stringByAppendingString:[_auth.app.options.googleAppID
|
||||
stringByReplacingOccurrencesOfString:@":"
|
||||
withString:@"-"]];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/** @fn OAuthResponseForURL:error:
|
||||
@brief Parses the redirected URL and returns a string representation of the OAuth response URL.
|
||||
@param URL The url to be parsed for an OAuth response URL.
|
||||
@param error The error that occurred if any.
|
||||
@return The OAuth response if successful.
|
||||
*/
|
||||
- (nullable NSString *)OAuthResponseForURL:(NSURL *)URL error:(NSError *_Nullable *_Nullable)error {
|
||||
NSDictionary<NSString *, NSString *> *URLQueryItems =
|
||||
[FIRAuthWebUtils dictionaryWithHttpArgumentsString:URL.query];
|
||||
NSURL *deepLinkURL = [NSURL URLWithString:URLQueryItems[@"deep_link_id"]];
|
||||
URLQueryItems = [FIRAuthWebUtils dictionaryWithHttpArgumentsString:deepLinkURL.query];
|
||||
NSString *queryItemLink = URLQueryItems[@"link"];
|
||||
if (queryItemLink) {
|
||||
return queryItemLink;
|
||||
}
|
||||
if (!error) {
|
||||
return nil;
|
||||
}
|
||||
NSData *errorData = [URLQueryItems[@"firebaseError"] dataUsingEncoding:NSUTF8StringEncoding];
|
||||
NSError *jsonError;
|
||||
NSDictionary *errorDict = [NSJSONSerialization JSONObjectWithData:errorData
|
||||
options:0
|
||||
error:&jsonError];
|
||||
if (jsonError) {
|
||||
*error = [FIRAuthErrorUtils JSONSerializationErrorWithUnderlyingError:jsonError];
|
||||
return nil;
|
||||
}
|
||||
*error = [FIRAuthErrorUtils URLResponseErrorWithCode:errorDict[@"code"]
|
||||
message:errorDict[@"message"]];
|
||||
if (!*error) {
|
||||
NSString *reason;
|
||||
if (errorDict[@"code"] && errorDict[@"message"]) {
|
||||
reason = [NSString stringWithFormat:@"[%@] - %@", errorDict[@"code"], errorDict[@"message"]];
|
||||
}
|
||||
*error = [FIRAuthErrorUtils webSignInUserInteractionFailureWithReason:reason];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
/** @fn getHeadFulLiteURLWithEventID:completion:
|
||||
@brief Constructs a URL used for opening a headful-lite flow using a given event
|
||||
ID and session ID.
|
||||
@param eventID The event ID used for this purpose.
|
||||
@param sessionID The session ID used when completing the headful lite flow.
|
||||
@param completion The callback invoked after the URL has been constructed or an error
|
||||
has been encountered.
|
||||
*/
|
||||
- (void)getHeadFulLiteURLWithEventID:(NSString *)eventID
|
||||
sessionID:(NSString *)sessionID
|
||||
completion:(FIRHeadfulLiteURLCallBack)completion {
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
[FIRAuthWebUtils
|
||||
fetchAuthDomainWithRequestConfiguration:_auth.requestConfiguration
|
||||
completion:^(NSString *_Nullable authDomain,
|
||||
NSError *_Nullable error) {
|
||||
if (error) {
|
||||
if (completion) {
|
||||
completion(nil, error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
__strong __typeof__(self) strongSelf = weakSelf;
|
||||
NSString *bundleID = [NSBundle mainBundle].bundleIdentifier;
|
||||
NSString *clientID = strongSelf->_auth.app.options.clientID;
|
||||
NSString *appID = strongSelf->_auth.app.options.googleAppID;
|
||||
NSString *apiKey =
|
||||
strongSelf->_auth.requestConfiguration.APIKey;
|
||||
NSMutableDictionary *urlArguments = [@{
|
||||
@"apiKey" : apiKey,
|
||||
@"authType" : kAuthTypeSignInWithRedirect,
|
||||
@"ibi" : bundleID ?: @"",
|
||||
@"sessionId" : [strongSelf hashforString:sessionID],
|
||||
@"v" : [FIRAuthBackend authUserAgent],
|
||||
@"eventId" : eventID,
|
||||
@"providerId" : strongSelf->_providerID,
|
||||
} mutableCopy];
|
||||
if (strongSelf->_usingClientIDScheme) {
|
||||
urlArguments[@"clientId"] = clientID;
|
||||
} else {
|
||||
urlArguments[@"appId"] = appID;
|
||||
}
|
||||
if (strongSelf.scopes.count) {
|
||||
urlArguments[@"scopes"] =
|
||||
[strongSelf.scopes componentsJoinedByString:@","];
|
||||
}
|
||||
if (strongSelf.customParameters.count) {
|
||||
NSString *customParameters =
|
||||
[strongSelf customParametersStringWithError:&error];
|
||||
if (error) {
|
||||
completion(nil, error);
|
||||
return;
|
||||
}
|
||||
if (customParameters) {
|
||||
urlArguments[@"customParameters"] = customParameters;
|
||||
}
|
||||
}
|
||||
if (strongSelf->_auth.requestConfiguration.languageCode) {
|
||||
urlArguments[@"hl"] =
|
||||
strongSelf->_auth.requestConfiguration.languageCode;
|
||||
}
|
||||
NSString *argumentsString = [strongSelf
|
||||
httpArgumentsStringForArgsDictionary:urlArguments];
|
||||
NSString *URLString;
|
||||
if (strongSelf->_auth.requestConfiguration
|
||||
.emulatorHostAndPort) {
|
||||
URLString = [NSString
|
||||
stringWithFormat:kHeadfulLiteEmulatorURLStringFormat,
|
||||
authDomain, argumentsString];
|
||||
} else {
|
||||
URLString =
|
||||
[NSString stringWithFormat:kHeadfulLiteURLStringFormat,
|
||||
authDomain, argumentsString];
|
||||
}
|
||||
if (completion) {
|
||||
NSCharacterSet *set =
|
||||
[NSCharacterSet URLFragmentAllowedCharacterSet];
|
||||
completion(
|
||||
[NSURL
|
||||
URLWithString:
|
||||
[URLString
|
||||
stringByAddingPercentEncodingWithAllowedCharacters:
|
||||
set]],
|
||||
nil);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
/** @fn customParametersString
|
||||
@brief Returns a JSON string representation of the custom parameters dictionary corresponding
|
||||
to the OAuthProvider.
|
||||
@return The JSON string representation of the custom parameters dictionary corresponding
|
||||
to the OAuthProvider.
|
||||
*/
|
||||
- (nullable NSString *)customParametersStringWithError:(NSError *_Nullable *_Nullable)error {
|
||||
if (!_customParameters.count) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (!error) {
|
||||
return nil;
|
||||
}
|
||||
NSError *jsonError;
|
||||
NSData *customParametersJSONData = [NSJSONSerialization dataWithJSONObject:_customParameters
|
||||
options:0
|
||||
error:&jsonError];
|
||||
if (jsonError) {
|
||||
*error = [FIRAuthErrorUtils JSONSerializationErrorWithUnderlyingError:jsonError];
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSString *customParamsRawJSON = [[NSString alloc] initWithData:customParametersJSONData
|
||||
encoding:NSUTF8StringEncoding];
|
||||
return customParamsRawJSON;
|
||||
}
|
||||
|
||||
/** @fn hashforString:
|
||||
@brief Returns the SHA256 hash representation of a given string object.
|
||||
@param string The string for which a SHA256 hash is desired.
|
||||
@return An hexadecimal string representation of the SHA256 hash.
|
||||
*/
|
||||
- (NSString *)hashforString:(NSString *)string {
|
||||
NSData *sessionIDData = [string dataUsingEncoding:NSUTF8StringEncoding];
|
||||
NSMutableData *hashOutputData = [NSMutableData dataWithLength:CC_SHA256_DIGEST_LENGTH];
|
||||
if (CC_SHA256(sessionIDData.bytes, (CC_LONG)[sessionIDData length],
|
||||
hashOutputData.mutableBytes)) {
|
||||
}
|
||||
return [self hexStringFromData:hashOutputData];
|
||||
;
|
||||
}
|
||||
|
||||
/** @fn hexStringFromData:
|
||||
@brief Returns the hexadecimal string representation of an NSData object.
|
||||
@param data The NSData object for which a hexadecical string is desired.
|
||||
@return The hexadecimal string representation of the supplied NSData object.
|
||||
*/
|
||||
- (NSString *)hexStringFromData:(NSData *)data {
|
||||
const unsigned char *dataBuffer = (const unsigned char *)[data bytes];
|
||||
NSMutableString *string = [[NSMutableString alloc] init];
|
||||
for (unsigned int i = 0; i < data.length; i++) {
|
||||
[string appendFormat:@"%02lx", (unsigned long)dataBuffer[i]];
|
||||
}
|
||||
return [string copy];
|
||||
}
|
||||
|
||||
- (NSString *)httpArgumentsStringForArgsDictionary:(NSDictionary *)argsDictionary {
|
||||
NSMutableArray *arguments = [NSMutableArray arrayWithCapacity:argsDictionary.count];
|
||||
NSString *key;
|
||||
for (key in argsDictionary) {
|
||||
NSString *description = [argsDictionary[key] description];
|
||||
[arguments
|
||||
addObject:[NSString
|
||||
stringWithFormat:@"%@=%@",
|
||||
[FIRAuthWebUtils stringByUnescapingFromURLArgument:key],
|
||||
[FIRAuthWebUtils
|
||||
stringByUnescapingFromURLArgument:description]]];
|
||||
}
|
||||
return [arguments componentsJoinedByString:@"&"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* 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 <TargetConditionals.h>
|
||||
#if TARGET_OS_IOS
|
||||
|
||||
#import "FirebaseAuth/Sources/Public/FirebaseAuth/FIRPhoneAuthCredential.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/AuthProvider/FIRAuthCredential_Internal.h"
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/FIRVerifyAssertionRequest.h"
|
||||
#import "FirebaseAuth/Sources/Utilities/FIRAuthExceptionUtils.h"
|
||||
|
||||
#if TARGET_OS_IOS
|
||||
#import "FirebaseAuth/Sources/AuthProvider/Phone/FIRPhoneAuthCredential_Internal.h"
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FIRPhoneAuthCredential ()
|
||||
|
||||
- (nullable instancetype)initWithProvider:(NSString *)provider NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FIRPhoneAuthCredential
|
||||
|
||||
- (instancetype)initWithTemporaryProof:(NSString *)temporaryProof
|
||||
phoneNumber:(NSString *)phoneNumber
|
||||
providerID:(NSString *)providerID {
|
||||
self = [super initWithProvider:providerID];
|
||||
if (self) {
|
||||
_temporaryProof = [temporaryProof copy];
|
||||
_phoneNumber = [phoneNumber copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithProvider:(NSString *)provider {
|
||||
[FIRAuthExceptionUtils
|
||||
raiseMethodNotImplementedExceptionWithReason:@"Please call the designated initializer."];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (instancetype)initWithProviderID:(NSString *)providerID
|
||||
verificationID:(NSString *)verificationID
|
||||
verificationCode:(NSString *)verificationCode {
|
||||
self = [super initWithProvider:providerID];
|
||||
if (self) {
|
||||
_verificationID = [verificationID copy];
|
||||
_verificationCode = [verificationCode copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - NSSecureCoding
|
||||
|
||||
+ (BOOL)supportsSecureCoding {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder {
|
||||
NSString *verificationID = [aDecoder decodeObjectOfClass:[NSString class]
|
||||
forKey:@"verificationID"];
|
||||
NSString *verificationCode = [aDecoder decodeObjectOfClass:[NSString class]
|
||||
forKey:@"verificationCode"];
|
||||
NSString *temporaryProof = [aDecoder decodeObjectOfClass:[NSString class]
|
||||
forKey:@"temporaryProof"];
|
||||
NSString *phoneNumber = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"phoneNumber"];
|
||||
if (temporaryProof.length && phoneNumber.length) {
|
||||
self = [self initWithTemporaryProof:temporaryProof
|
||||
phoneNumber:phoneNumber
|
||||
providerID:self.provider];
|
||||
} else if (verificationID.length && verificationCode.length) {
|
||||
self = [self initWithProviderID:self.provider
|
||||
verificationID:verificationID
|
||||
verificationCode:verificationCode];
|
||||
} else {
|
||||
self = nil;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)aCoder {
|
||||
[aCoder encodeObject:self.verificationID forKey:@"verificationID"];
|
||||
[aCoder encodeObject:self.verificationCode forKey:@"verificationCode"];
|
||||
[aCoder encodeObject:self.temporaryProof forKey:@"temporaryProof"];
|
||||
[aCoder encodeObject:self.phoneNumber forKey:@"phoneNumber"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
#endif
|
||||
Generated
+73
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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 <TargetConditionals.h>
|
||||
#if TARGET_OS_IOS
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "FirebaseAuth/Sources/Public/FirebaseAuth/FIRPhoneAuthCredential.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @extension FIRPhoneAuthCredential
|
||||
@brief Internal implementation of FIRAuthCredential for Phone Auth credentials.
|
||||
*/
|
||||
@interface FIRPhoneAuthCredential ()
|
||||
|
||||
/** @var verificationID
|
||||
@brief The verification ID obtained from invoking @c verifyPhoneNumber:completion:
|
||||
*/
|
||||
@property(nonatomic, readonly, nonnull) NSString *verificationID;
|
||||
|
||||
/** @var verificationCode
|
||||
@brief The verification code provided by the user.
|
||||
*/
|
||||
@property(nonatomic, readonly, nonnull) NSString *verificationCode;
|
||||
|
||||
/** @var temporaryProof
|
||||
@brief The a temporary proof code perftaining to this credential, returned from the backend.
|
||||
*/
|
||||
@property(nonatomic, readonly, nonnull) NSString *temporaryProof;
|
||||
|
||||
/** @var phoneNumber
|
||||
@brief The a phone number pertaining to this credential, returned from the backend.
|
||||
*/
|
||||
@property(nonatomic, readonly, nonnull) NSString *phoneNumber;
|
||||
|
||||
/** @var initWithTemporaryProof:phoneNumber:
|
||||
@brief Designated Initializer.
|
||||
@param providerID The provider ID associated with the phone auth credential being created.
|
||||
*/
|
||||
- (instancetype)initWithTemporaryProof:(NSString *)temporaryProof
|
||||
phoneNumber:(NSString *)phoneNumber
|
||||
providerID:(NSString *)providerID NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
/** @var initWithProviderID:verificationID:verificationCode:
|
||||
@brief Designated Initializer.
|
||||
@param providerID The provider ID associated with the phone auth credential being created.
|
||||
@param verificationID The verification ID associated witht Phone Auth credential being created.
|
||||
@param verificationCode The verification code associated witht Phone Auth credential being
|
||||
created.
|
||||
*/
|
||||
- (instancetype)initWithProviderID:(NSString *)providerID
|
||||
verificationID:(NSString *)verificationID
|
||||
verificationCode:(NSString *)verificationCode NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
#endif
|
||||
+754
@@ -0,0 +1,754 @@
|
||||
/*
|
||||
* 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 <TargetConditionals.h>
|
||||
#if TARGET_OS_IOS
|
||||
|
||||
#import "FirebaseAuth/Sources/Public/FirebaseAuth/FIRAuthSettings.h"
|
||||
#import "FirebaseAuth/Sources/Public/FirebaseAuth/FIRMultiFactorResolver.h"
|
||||
#import "FirebaseAuth/Sources/Public/FirebaseAuth/FIRPhoneAuthProvider.h"
|
||||
#import "FirebaseCore/Sources/Private/FirebaseCoreInternal.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/Auth/FIRAuthGlobalWorkQueue.h"
|
||||
#import "FirebaseAuth/Sources/Auth/FIRAuth_Internal.h"
|
||||
#import "FirebaseAuth/Sources/Backend/FIRAuthBackend+MultiFactor.h"
|
||||
#import "FirebaseAuth/Sources/Backend/FIRAuthBackend.h"
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/FIRGetProjectConfigRequest.h"
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/FIRGetProjectConfigResponse.h"
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/FIRSendVerificationCodeRequest.h"
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/FIRSendVerificationCodeResponse.h"
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/FIRVerifyClientRequest.h"
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/FIRVerifyClientResponse.h"
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/MultiFactor/Enroll/FIRStartMFAEnrollmentRequest.h"
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/MultiFactor/Enroll/FIRStartMFAEnrollmentResponse.h"
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/Proto/Phone/FIRAuthProtoStartMFAPhoneRequestInfo.h"
|
||||
#import "FirebaseAuth/Sources/MultiFactor/FIRMultiFactorSession+Internal.h"
|
||||
#import "FirebaseAuth/Sources/SystemService/FIRAuthAPNSToken.h"
|
||||
#import "FirebaseAuth/Sources/SystemService/FIRAuthAPNSTokenManager.h"
|
||||
#import "FirebaseAuth/Sources/SystemService/FIRAuthAppCredential.h"
|
||||
#import "FirebaseAuth/Sources/SystemService/FIRAuthAppCredentialManager.h"
|
||||
#import "FirebaseAuth/Sources/SystemService/FIRAuthNotificationManager.h"
|
||||
#import "FirebaseAuth/Sources/Utilities/FIRAuthErrorUtils.h"
|
||||
#import "FirebaseAuth/Sources/Utilities/FIRAuthURLPresenter.h"
|
||||
#import "FirebaseAuth/Sources/Utilities/FIRAuthWebUtils.h"
|
||||
|
||||
#if TARGET_OS_IOS
|
||||
#import "FirebaseAuth/Sources/AuthProvider/Phone/FIRPhoneAuthCredential_Internal.h"
|
||||
#import "FirebaseAuth/Sources/MultiFactor/Phone/FIRPhoneMultiFactorInfo+Internal.h"
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @typedef FIRReCAPTCHAURLCallBack
|
||||
@brief The callback invoked at the end of the flow to fetch a reCAPTCHA URL.
|
||||
@param reCAPTCHAURL The reCAPTCHA URL.
|
||||
@param error The error that occurred while fetching the reCAPTCHAURL, if any.
|
||||
*/
|
||||
typedef void (^FIRReCAPTCHAURLCallBack)(NSURL *_Nullable reCAPTCHAURL, NSError *_Nullable error);
|
||||
|
||||
/** @typedef FIRVerifyClientCallback
|
||||
@brief The callback invoked at the end of a client verification flow.
|
||||
@param appCredential credential that proves the identity of the app during a phone
|
||||
authentication flow.
|
||||
@param error The error that occurred while verifying the app, if any.
|
||||
*/
|
||||
typedef void (^FIRVerifyClientCallback)(FIRAuthAppCredential *_Nullable appCredential,
|
||||
NSString *_Nullable reCAPTCHAToken,
|
||||
NSError *_Nullable error);
|
||||
|
||||
/** @typedef FIRFetchAuthDomainCallback
|
||||
@brief The callback invoked at the end of the flow to fetch the Auth domain.
|
||||
@param authDomain The Auth domain.
|
||||
@param error The error that occurred while fetching the auth domain, if any.
|
||||
*/
|
||||
typedef void (^FIRFetchAuthDomainCallback)(NSString *_Nullable authDomain,
|
||||
NSError *_Nullable error);
|
||||
|
||||
/** @var kauthTypeVerifyApp
|
||||
@brief The auth type to be specified in the app verification request.
|
||||
*/
|
||||
static NSString *const kAuthTypeVerifyApp = @"verifyApp";
|
||||
|
||||
/** @var kCustomUrlSchemePrefix
|
||||
@brief The prefix to append to the Firebase app ID custom callback scheme..
|
||||
*/
|
||||
static NSString *const kCustomUrlSchemePrefix = @"app-";
|
||||
|
||||
/** @var kReCAPTCHAURLStringFormat
|
||||
@brief The format of the URL used to open the reCAPTCHA page during app verification.
|
||||
*/
|
||||
NSString *const kReCAPTCHAURLStringFormat = @"https://%@/__/auth/handler?";
|
||||
|
||||
extern NSString *const FIRPhoneMultiFactorID;
|
||||
|
||||
@implementation FIRPhoneAuthProvider {
|
||||
/** @var _auth
|
||||
@brief The auth instance used for verifying the phone number.
|
||||
*/
|
||||
FIRAuth *_auth;
|
||||
|
||||
/** @var _callbackScheme
|
||||
@brief The callback URL scheme used for reCAPTCHA fallback.
|
||||
*/
|
||||
NSString *_callbackScheme;
|
||||
|
||||
/** @var _usingClientIDScheme
|
||||
@brief True if the reverse client ID is registered as a custom URL scheme, and false
|
||||
otherwise.
|
||||
*/
|
||||
BOOL _usingClientIDScheme;
|
||||
}
|
||||
|
||||
/** @fn initWithAuth:
|
||||
@brief returns an instance of @c FIRPhoneAuthProvider associated with the provided auth
|
||||
instance.
|
||||
@return An Instance of @c FIRPhoneAuthProvider.
|
||||
*/
|
||||
- (nullable instancetype)initWithAuth:(FIRAuth *)auth {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_auth = auth;
|
||||
if (_auth.app.options.clientID) {
|
||||
NSString *reverseClientIDScheme =
|
||||
[[[_auth.app.options.clientID componentsSeparatedByString:@"."]
|
||||
reverseObjectEnumerator].allObjects componentsJoinedByString:@"."];
|
||||
if ([FIRAuthWebUtils isCallbackSchemeRegisteredForCustomURLScheme:reverseClientIDScheme]) {
|
||||
_callbackScheme = reverseClientIDScheme;
|
||||
_usingClientIDScheme = YES;
|
||||
}
|
||||
}
|
||||
if (!_usingClientIDScheme) {
|
||||
_callbackScheme = [kCustomUrlSchemePrefix
|
||||
stringByAppendingString:[_auth.app.options.googleAppID
|
||||
stringByReplacingOccurrencesOfString:@":"
|
||||
withString:@"-"]];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)verifyPhoneNumber:(NSString *)phoneNumber
|
||||
UIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
|
||||
completion:(nullable FIRVerificationResultCallback)completion {
|
||||
if (![FIRAuthWebUtils isCallbackSchemeRegisteredForCustomURLScheme:_callbackScheme]) {
|
||||
[NSException raise:NSInternalInconsistencyException
|
||||
format:@"Please register custom URL scheme '%@' in the app's Info.plist file.",
|
||||
_callbackScheme];
|
||||
}
|
||||
dispatch_async(FIRAuthGlobalWorkQueue(), ^{
|
||||
FIRVerificationResultCallback callBackOnMainThread =
|
||||
^(NSString *_Nullable verificationID, NSError *_Nullable error) {
|
||||
if (completion) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
completion(verificationID, error);
|
||||
});
|
||||
}
|
||||
};
|
||||
[self
|
||||
internalVerifyPhoneNumber:phoneNumber
|
||||
UIDelegate:UIDelegate
|
||||
completion:^(NSString *_Nullable verificationID, NSError *_Nullable error) {
|
||||
if (!error) {
|
||||
callBackOnMainThread(verificationID, nil);
|
||||
return;
|
||||
} else {
|
||||
callBackOnMainThread(nil, error);
|
||||
return;
|
||||
}
|
||||
}];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)verifyPhoneNumberWithMultiFactorInfo:(FIRPhoneMultiFactorInfo *)phoneMultiFactorInfo
|
||||
UIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
|
||||
multiFactorSession:(nullable FIRMultiFactorSession *)session
|
||||
completion:(nullable FIRVerificationResultCallback)completion {
|
||||
session.multiFactorInfo = phoneMultiFactorInfo;
|
||||
[self verifyPhoneNumber:phoneMultiFactorInfo.phoneNumber
|
||||
UIDelegate:UIDelegate
|
||||
multiFactorSession:session
|
||||
completion:completion];
|
||||
}
|
||||
|
||||
- (void)verifyPhoneNumber:(NSString *)phoneNumber
|
||||
UIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
|
||||
multiFactorSession:(nullable FIRMultiFactorSession *)session
|
||||
completion:(nullable FIRVerificationResultCallback)completion {
|
||||
if (!session) {
|
||||
[self verifyPhoneNumber:phoneNumber UIDelegate:UIDelegate completion:completion];
|
||||
return;
|
||||
}
|
||||
|
||||
if (![FIRAuthWebUtils isCallbackSchemeRegisteredForCustomURLScheme:_callbackScheme]) {
|
||||
[NSException raise:NSInternalInconsistencyException
|
||||
format:@"Please register custom URL scheme '%@' in the app's Info.plist file.",
|
||||
_callbackScheme];
|
||||
}
|
||||
dispatch_async(FIRAuthGlobalWorkQueue(), ^{
|
||||
FIRVerificationResultCallback callBackOnMainThread =
|
||||
^(NSString *_Nullable verificationID, NSError *_Nullable error) {
|
||||
if (completion) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
completion(verificationID, error);
|
||||
});
|
||||
}
|
||||
};
|
||||
[self
|
||||
internalVerifyPhoneNumber:phoneNumber
|
||||
UIDelegate:UIDelegate
|
||||
multiFactorSession:session
|
||||
completion:^(NSString *_Nullable verificationID, NSError *_Nullable error) {
|
||||
if (!error) {
|
||||
callBackOnMainThread(verificationID, nil);
|
||||
return;
|
||||
} else {
|
||||
callBackOnMainThread(nil, error);
|
||||
return;
|
||||
}
|
||||
}];
|
||||
});
|
||||
}
|
||||
|
||||
- (FIRPhoneAuthCredential *)credentialWithVerificationID:(NSString *)verificationID
|
||||
verificationCode:(NSString *)verificationCode {
|
||||
return [[FIRPhoneAuthCredential alloc] initWithProviderID:FIRPhoneAuthProviderID
|
||||
verificationID:verificationID
|
||||
verificationCode:verificationCode];
|
||||
}
|
||||
|
||||
+ (instancetype)provider {
|
||||
return [[self alloc] initWithAuth:[FIRAuth auth]];
|
||||
}
|
||||
|
||||
+ (instancetype)providerWithAuth:(FIRAuth *)auth {
|
||||
return [[self alloc] initWithAuth:auth];
|
||||
}
|
||||
|
||||
#pragma mark - Internal Methods
|
||||
|
||||
/** @fn reCAPTCHATokenForURL:error:
|
||||
@brief Parses the reCAPTCHA URL and returns the reCAPTCHA token.
|
||||
@param URL The url to be parsed for a reCAPTCHA token.
|
||||
@param error The error that occurred if any.
|
||||
@return The reCAPTCHA token if successful.
|
||||
*/
|
||||
- (nullable NSString *)reCAPTCHATokenForURL:(NSURL *)URL error:(NSError **_Nonnull)error {
|
||||
NSURLComponents *actualURLComponents = [NSURLComponents componentsWithURL:URL
|
||||
resolvingAgainstBaseURL:NO];
|
||||
NSArray<NSURLQueryItem *> *queryItems = [actualURLComponents queryItems];
|
||||
NSString *deepLinkURL = [FIRAuthWebUtils queryItemValue:@"deep_link_id" from:queryItems];
|
||||
NSData *errorData;
|
||||
if (deepLinkURL) {
|
||||
actualURLComponents = [NSURLComponents componentsWithString:deepLinkURL];
|
||||
queryItems = [actualURLComponents queryItems];
|
||||
NSString *recaptchaToken = [FIRAuthWebUtils queryItemValue:@"recaptchaToken" from:queryItems];
|
||||
if (recaptchaToken) {
|
||||
return recaptchaToken;
|
||||
}
|
||||
NSString *firebaseError = [FIRAuthWebUtils queryItemValue:@"firebaseError" from:queryItems];
|
||||
errorData = [firebaseError dataUsingEncoding:NSUTF8StringEncoding];
|
||||
} else {
|
||||
errorData = nil;
|
||||
}
|
||||
if (error != NULL && errorData != nil) {
|
||||
NSError *jsonError;
|
||||
NSDictionary *errorDict = [NSJSONSerialization JSONObjectWithData:errorData
|
||||
options:0
|
||||
error:&jsonError];
|
||||
if (jsonError) {
|
||||
*error = [FIRAuthErrorUtils JSONSerializationErrorWithUnderlyingError:jsonError];
|
||||
return nil;
|
||||
}
|
||||
*error = [FIRAuthErrorUtils URLResponseErrorWithCode:errorDict[@"code"]
|
||||
message:errorDict[@"message"]];
|
||||
if (!*error) {
|
||||
NSString *reason;
|
||||
if (errorDict[@"code"] && errorDict[@"message"]) {
|
||||
reason =
|
||||
[NSString stringWithFormat:@"[%@] - %@", errorDict[@"code"], errorDict[@"message"]];
|
||||
} else {
|
||||
reason = [NSString stringWithFormat:@"An unknown error occurred with the following "
|
||||
"response: %@",
|
||||
deepLinkURL];
|
||||
}
|
||||
*error = [FIRAuthErrorUtils appVerificationUserInteractionFailureWithReason:reason];
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
/** @fn internalVerifyPhoneNumber:completion:
|
||||
@brief Starts the phone number authentication flow by sending a verifcation code to the
|
||||
specified phone number.
|
||||
@param phoneNumber The phone number to be verified.
|
||||
@param completion The callback to be invoked when the verification flow is finished.
|
||||
*/
|
||||
|
||||
- (void)internalVerifyPhoneNumber:(NSString *)phoneNumber
|
||||
UIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
|
||||
completion:(nullable FIRVerificationResultCallback)completion {
|
||||
if (!phoneNumber.length) {
|
||||
completion(nil, [FIRAuthErrorUtils missingPhoneNumberErrorWithMessage:nil]);
|
||||
return;
|
||||
}
|
||||
[_auth.notificationManager
|
||||
checkNotificationForwardingWithCallback:^(BOOL isNotificationBeingForwarded) {
|
||||
if (!isNotificationBeingForwarded) {
|
||||
completion(nil, [FIRAuthErrorUtils notificationNotForwardedError]);
|
||||
return;
|
||||
}
|
||||
FIRVerificationResultCallback callback =
|
||||
^(NSString *_Nullable verificationID, NSError *_Nullable error) {
|
||||
if (completion) {
|
||||
completion(verificationID, error);
|
||||
}
|
||||
};
|
||||
[self verifyClientAndSendVerificationCodeToPhoneNumber:phoneNumber
|
||||
retryOnInvalidAppCredential:YES
|
||||
UIDelegate:UIDelegate
|
||||
callback:callback];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)internalVerifyPhoneNumber:(NSString *)phoneNumber
|
||||
UIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
|
||||
multiFactorSession:(nullable FIRMultiFactorSession *)session
|
||||
completion:(nullable FIRVerificationResultCallback)completion {
|
||||
if (!phoneNumber.length) {
|
||||
if (completion) {
|
||||
completion(nil, [FIRAuthErrorUtils missingPhoneNumberErrorWithMessage:nil]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
[_auth.notificationManager
|
||||
checkNotificationForwardingWithCallback:^(BOOL isNotificationBeingForwarded) {
|
||||
if (!isNotificationBeingForwarded) {
|
||||
if (completion) {
|
||||
completion(nil, [FIRAuthErrorUtils notificationNotForwardedError]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
FIRVerificationResultCallback callback =
|
||||
^(NSString *_Nullable verificationID, NSError *_Nullable error) {
|
||||
if (completion) {
|
||||
completion(verificationID, error);
|
||||
}
|
||||
};
|
||||
[self verifyClientAndSendVerificationCodeToPhoneNumber:phoneNumber
|
||||
retryOnInvalidAppCredential:YES
|
||||
UIDelegate:UIDelegate
|
||||
multiFactorSession:session
|
||||
callback:callback];
|
||||
}];
|
||||
}
|
||||
|
||||
/** @fn verifyClientAndSendVerificationCodeToPhoneNumber:retryOnInvalidAppCredential:callback:
|
||||
@brief Starts the flow to verify the client via silent push notification.
|
||||
@param retryOnInvalidAppCredential Whether of not the flow should be retried if an
|
||||
FIRAuthErrorCodeInvalidAppCredential error is returned from the backend.
|
||||
@param phoneNumber The phone number to be verified.
|
||||
@param callback The callback to be invoked on the global work queue when the flow is
|
||||
finished.
|
||||
*/
|
||||
- (void)verifyClientAndSendVerificationCodeToPhoneNumber:(NSString *)phoneNumber
|
||||
retryOnInvalidAppCredential:(BOOL)retryOnInvalidAppCredential
|
||||
UIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
|
||||
callback:(FIRVerificationResultCallback)callback {
|
||||
if (_auth.settings.isAppVerificationDisabledForTesting) {
|
||||
FIRSendVerificationCodeRequest *request =
|
||||
[[FIRSendVerificationCodeRequest alloc] initWithPhoneNumber:phoneNumber
|
||||
appCredential:nil
|
||||
reCAPTCHAToken:nil
|
||||
requestConfiguration:_auth.requestConfiguration];
|
||||
[FIRAuthBackend sendVerificationCode:request
|
||||
callback:^(FIRSendVerificationCodeResponse *_Nullable response,
|
||||
NSError *_Nullable error) {
|
||||
callback(response.verificationID, error);
|
||||
}];
|
||||
return;
|
||||
}
|
||||
[self
|
||||
verifyClientWithUIDelegate:UIDelegate
|
||||
completion:^(FIRAuthAppCredential *_Nullable appCredential,
|
||||
NSString *_Nullable reCAPTCHAToken, NSError *_Nullable error) {
|
||||
if (error) {
|
||||
callback(nil, error);
|
||||
return;
|
||||
}
|
||||
FIRSendVerificationCodeRequest *_Nullable request;
|
||||
if (appCredential) {
|
||||
request = [[FIRSendVerificationCodeRequest alloc]
|
||||
initWithPhoneNumber:phoneNumber
|
||||
appCredential:appCredential
|
||||
reCAPTCHAToken:nil
|
||||
requestConfiguration:self->_auth.requestConfiguration];
|
||||
} else if (reCAPTCHAToken) {
|
||||
request = [[FIRSendVerificationCodeRequest alloc]
|
||||
initWithPhoneNumber:phoneNumber
|
||||
appCredential:nil
|
||||
reCAPTCHAToken:reCAPTCHAToken
|
||||
requestConfiguration:self->_auth.requestConfiguration];
|
||||
}
|
||||
if (request) {
|
||||
[FIRAuthBackend
|
||||
sendVerificationCode:request
|
||||
callback:^(
|
||||
FIRSendVerificationCodeResponse *_Nullable response,
|
||||
NSError *_Nullable error) {
|
||||
if (error) {
|
||||
if (error.code ==
|
||||
FIRAuthErrorCodeInvalidAppCredential) {
|
||||
if (retryOnInvalidAppCredential) {
|
||||
[self->_auth
|
||||
.appCredentialManager clearCredential];
|
||||
[self
|
||||
verifyClientAndSendVerificationCodeToPhoneNumber:
|
||||
phoneNumber
|
||||
retryOnInvalidAppCredential:
|
||||
NO
|
||||
UIDelegate:
|
||||
UIDelegate
|
||||
callback:
|
||||
callback];
|
||||
return;
|
||||
}
|
||||
callback(
|
||||
nil,
|
||||
[FIRAuthErrorUtils
|
||||
unexpectedResponseWithDeserializedResponse:
|
||||
nil
|
||||
underlyingError:
|
||||
error]);
|
||||
return;
|
||||
}
|
||||
callback(nil, error);
|
||||
return;
|
||||
}
|
||||
callback(response.verificationID, nil);
|
||||
}];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)verifyClientAndSendVerificationCodeToPhoneNumber:(NSString *)phoneNumber
|
||||
retryOnInvalidAppCredential:(BOOL)retryOnInvalidAppCredential
|
||||
UIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
|
||||
multiFactorSession:(nullable FIRMultiFactorSession *)session
|
||||
callback:(FIRVerificationResultCallback)callback {
|
||||
if (_auth.settings.isAppVerificationDisabledForTesting) {
|
||||
FIRSendVerificationCodeRequest *request =
|
||||
[[FIRSendVerificationCodeRequest alloc] initWithPhoneNumber:phoneNumber
|
||||
appCredential:nil
|
||||
reCAPTCHAToken:nil
|
||||
requestConfiguration:_auth.requestConfiguration];
|
||||
[FIRAuthBackend sendVerificationCode:request
|
||||
callback:^(FIRSendVerificationCodeResponse *_Nullable response,
|
||||
NSError *_Nullable error) {
|
||||
callback(response.verificationID, error);
|
||||
}];
|
||||
return;
|
||||
}
|
||||
|
||||
[self
|
||||
verifyClientWithUIDelegate:UIDelegate
|
||||
completion:^(FIRAuthAppCredential *_Nullable appCredential,
|
||||
NSString *_Nullable reCAPTCHAToken, NSError *_Nullable error) {
|
||||
if (error) {
|
||||
if (callback) {
|
||||
callback(nil, error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *IDToken = session.IDToken;
|
||||
FIRAuthProtoStartMFAPhoneRequestInfo *startMFARequestInfo =
|
||||
[[FIRAuthProtoStartMFAPhoneRequestInfo alloc]
|
||||
initWithPhoneNumber:phoneNumber
|
||||
appCredential:appCredential
|
||||
reCAPTCHAToken:reCAPTCHAToken];
|
||||
if (session.IDToken) {
|
||||
FIRStartMFAEnrollmentRequest *request =
|
||||
[[FIRStartMFAEnrollmentRequest alloc]
|
||||
initWithIDToken:IDToken
|
||||
enrollmentInfo:startMFARequestInfo
|
||||
requestConfiguration:self->_auth.requestConfiguration];
|
||||
[FIRAuthBackend
|
||||
startMultiFactorEnrollment:request
|
||||
callback:^(FIRStartMFAEnrollmentResponse
|
||||
*_Nullable response,
|
||||
NSError *_Nullable error) {
|
||||
if (error) {
|
||||
if (error.code ==
|
||||
FIRAuthErrorCodeInvalidAppCredential) {
|
||||
if (retryOnInvalidAppCredential) {
|
||||
[self->_auth.appCredentialManager
|
||||
clearCredential];
|
||||
[self
|
||||
verifyClientAndSendVerificationCodeToPhoneNumber:
|
||||
phoneNumber
|
||||
retryOnInvalidAppCredential:
|
||||
NO
|
||||
UIDelegate:
|
||||
UIDelegate
|
||||
multiFactorSession:
|
||||
session
|
||||
callback:
|
||||
callback];
|
||||
return;
|
||||
}
|
||||
if (callback) {
|
||||
callback(
|
||||
nil,
|
||||
[FIRAuthErrorUtils
|
||||
unexpectedResponseWithDeserializedResponse:
|
||||
nil
|
||||
underlyingError:
|
||||
error]);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
if (callback) {
|
||||
callback(nil, error);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (callback) {
|
||||
callback(
|
||||
response.enrollmentResponse.sessionInfo,
|
||||
nil);
|
||||
}
|
||||
}
|
||||
}];
|
||||
} else {
|
||||
FIRStartMFASignInRequest *request = [[FIRStartMFASignInRequest alloc]
|
||||
initWithMFAPendingCredential:session.MFAPendingCredential
|
||||
MFAEnrollmentID:session.multiFactorInfo.UID
|
||||
signInInfo:startMFARequestInfo
|
||||
requestConfiguration:self->_auth.requestConfiguration];
|
||||
[FIRAuthBackend
|
||||
startMultiFactorSignIn:request
|
||||
callback:^(
|
||||
FIRStartMFASignInResponse *_Nullable response,
|
||||
NSError *_Nullable error) {
|
||||
if (error) {
|
||||
if (error.code ==
|
||||
FIRAuthErrorCodeInvalidAppCredential) {
|
||||
if (retryOnInvalidAppCredential) {
|
||||
[self->_auth
|
||||
.appCredentialManager clearCredential];
|
||||
[self
|
||||
verifyClientAndSendVerificationCodeToPhoneNumber:
|
||||
phoneNumber
|
||||
retryOnInvalidAppCredential:
|
||||
NO
|
||||
UIDelegate:
|
||||
UIDelegate
|
||||
multiFactorSession:
|
||||
session
|
||||
callback:
|
||||
callback];
|
||||
return;
|
||||
}
|
||||
if (callback) {
|
||||
callback(
|
||||
nil,
|
||||
[FIRAuthErrorUtils
|
||||
unexpectedResponseWithDeserializedResponse:
|
||||
nil
|
||||
underlyingError:
|
||||
error]);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
if (callback) {
|
||||
callback(nil, error);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (callback) {
|
||||
callback(response.responseInfo.sessionInfo, nil);
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
/** @fn verifyClientWithCompletion:completion:
|
||||
@brief Continues the flow to verify the client via silent push notification.
|
||||
@param completion The callback to be invoked when the client verification flow is finished.
|
||||
*/
|
||||
- (void)verifyClientWithUIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
|
||||
completion:(FIRVerifyClientCallback)completion {
|
||||
if (_auth.appCredentialManager.credential) {
|
||||
completion(_auth.appCredentialManager.credential, nil, nil);
|
||||
return;
|
||||
}
|
||||
[_auth.tokenManager getTokenWithCallback:^(FIRAuthAPNSToken *_Nullable token,
|
||||
NSError *_Nullable error) {
|
||||
if (!token) {
|
||||
[self reCAPTCHAFlowWithUIDelegate:UIDelegate completion:completion];
|
||||
return;
|
||||
}
|
||||
FIRVerifyClientRequest *request =
|
||||
[[FIRVerifyClientRequest alloc] initWithAppToken:token.string
|
||||
isSandbox:token.type == FIRAuthAPNSTokenTypeSandbox
|
||||
requestConfiguration:self->_auth.requestConfiguration];
|
||||
[FIRAuthBackend
|
||||
verifyClient:request
|
||||
callback:^(FIRVerifyClientResponse *_Nullable response, NSError *_Nullable error) {
|
||||
if (error) {
|
||||
NSError *underlyingError = error.userInfo[NSUnderlyingErrorKey];
|
||||
BOOL isInvalidAppCredential =
|
||||
error.code == FIRAuthErrorCodeInternalError &&
|
||||
underlyingError.code == FIRAuthErrorCodeInvalidAppCredential;
|
||||
if (error.code != FIRAuthErrorCodeMissingAppToken && !isInvalidAppCredential) {
|
||||
completion(nil, nil, error);
|
||||
return;
|
||||
} else {
|
||||
[self reCAPTCHAFlowWithUIDelegate:UIDelegate completion:completion];
|
||||
return;
|
||||
}
|
||||
}
|
||||
NSTimeInterval timeout = [response.suggestedTimeOutDate timeIntervalSinceNow];
|
||||
[self->_auth.appCredentialManager
|
||||
didStartVerificationWithReceipt:response.receipt
|
||||
timeout:timeout
|
||||
callback:^(FIRAuthAppCredential *credential) {
|
||||
if (!credential.secret) {
|
||||
FIRLogWarning(kFIRLoggerAuth, @"I-AUT000014",
|
||||
@"Failed to receive remote notification "
|
||||
@"to verify app identity within "
|
||||
@"%.0f second(s), falling back to "
|
||||
@"reCAPTCHA verification.",
|
||||
timeout);
|
||||
[self reCAPTCHAFlowWithUIDelegate:UIDelegate
|
||||
completion:completion];
|
||||
return;
|
||||
}
|
||||
completion(credential, nil, nil);
|
||||
}];
|
||||
}];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)reCAPTCHAFlowWithUIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
|
||||
completion:(FIRVerifyClientCallback)completion {
|
||||
NSString *eventID = [FIRAuthWebUtils randomStringWithLength:10];
|
||||
[self
|
||||
reCAPTCHAURLWithEventID:eventID
|
||||
completion:^(NSURL *_Nullable reCAPTCHAURL, NSError *_Nullable error) {
|
||||
if (error) {
|
||||
completion(nil, nil, error);
|
||||
return;
|
||||
}
|
||||
FIRAuthURLCallbackMatcher callbackMatcher =
|
||||
^BOOL(NSURL *_Nullable callbackURL) {
|
||||
return [FIRAuthWebUtils isExpectedCallbackURL:callbackURL
|
||||
eventID:eventID
|
||||
authType:kAuthTypeVerifyApp
|
||||
callbackScheme:self->_callbackScheme];
|
||||
};
|
||||
[self->_auth.authURLPresenter
|
||||
presentURL:reCAPTCHAURL
|
||||
UIDelegate:UIDelegate
|
||||
callbackMatcher:callbackMatcher
|
||||
completion:^(NSURL *_Nullable callbackURL, NSError *_Nullable error) {
|
||||
if (error) {
|
||||
completion(nil, nil, error);
|
||||
return;
|
||||
}
|
||||
NSError *reCAPTCHAError;
|
||||
NSString *reCAPTCHAToken =
|
||||
[self reCAPTCHATokenForURL:callbackURL error:&reCAPTCHAError];
|
||||
if (!reCAPTCHAToken) {
|
||||
completion(nil, nil, reCAPTCHAError);
|
||||
return;
|
||||
} else {
|
||||
completion(nil, reCAPTCHAToken, nil);
|
||||
return;
|
||||
}
|
||||
}];
|
||||
}];
|
||||
}
|
||||
|
||||
/** @fn reCAPTCHAURLWithEventID:completion:
|
||||
@brief Constructs a URL used for opening a reCAPTCHA app verification flow using a given event
|
||||
ID.
|
||||
@param eventID The event ID used for this purpose.
|
||||
@param completion The callback invoked after the URL has been constructed or an error
|
||||
has been encountered.
|
||||
*/
|
||||
- (void)reCAPTCHAURLWithEventID:(NSString *)eventID completion:(FIRReCAPTCHAURLCallBack)completion {
|
||||
[FIRAuthWebUtils
|
||||
fetchAuthDomainWithRequestConfiguration:_auth.requestConfiguration
|
||||
completion:^(NSString *_Nullable authDomain,
|
||||
NSError *_Nullable error) {
|
||||
if (error) {
|
||||
if (completion) {
|
||||
completion(nil, error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
NSString *bundleID = [NSBundle mainBundle].bundleIdentifier;
|
||||
NSString *clientID = self->_auth.app.options.clientID;
|
||||
NSString *appID = self->_auth.app.options.googleAppID;
|
||||
NSString *apiKey = self->_auth.requestConfiguration.APIKey;
|
||||
NSMutableArray<NSURLQueryItem *> *queryItems = [@[
|
||||
[NSURLQueryItem queryItemWithName:@"apiKey" value:apiKey],
|
||||
[NSURLQueryItem queryItemWithName:@"authType"
|
||||
value:kAuthTypeVerifyApp],
|
||||
[NSURLQueryItem queryItemWithName:@"ibi"
|
||||
value:bundleID ?: @""],
|
||||
[NSURLQueryItem
|
||||
queryItemWithName:@"v"
|
||||
value:[FIRAuthBackend authUserAgent]],
|
||||
[NSURLQueryItem queryItemWithName:@"eventId" value:eventID]
|
||||
] mutableCopy];
|
||||
if (self->_usingClientIDScheme) {
|
||||
[queryItems
|
||||
addObject:[NSURLQueryItem queryItemWithName:@"clientId"
|
||||
value:clientID]];
|
||||
} else {
|
||||
[queryItems
|
||||
addObject:[NSURLQueryItem queryItemWithName:@"appId"
|
||||
value:appID]];
|
||||
}
|
||||
|
||||
if (self->_auth.requestConfiguration.languageCode) {
|
||||
[queryItems
|
||||
addObject:[NSURLQueryItem
|
||||
queryItemWithName:@"hl"
|
||||
value:self->_auth
|
||||
.requestConfiguration
|
||||
.languageCode]];
|
||||
}
|
||||
NSURLComponents *components = [[NSURLComponents alloc]
|
||||
initWithString:
|
||||
[NSString stringWithFormat:kReCAPTCHAURLStringFormat,
|
||||
authDomain]];
|
||||
[components setQueryItems:queryItems];
|
||||
if (completion) {
|
||||
completion([components URL], nil);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
#endif
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/AuthProvider/FIRAuthCredential_Internal.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @class FIRTwitterAuthCredential
|
||||
@brief Internal implementation of FIRAuthCredential for Twitter credentials.
|
||||
*/
|
||||
@interface FIRTwitterAuthCredential : FIRAuthCredential <NSSecureCoding>
|
||||
|
||||
/** @property token
|
||||
@brief The Twitter OAuth token.
|
||||
*/
|
||||
@property(nonatomic, readonly) NSString *token;
|
||||
|
||||
/** @property secret
|
||||
@brief The Twitter OAuth secret.
|
||||
*/
|
||||
@property(nonatomic, readonly) NSString *secret;
|
||||
|
||||
/** @fn initWithToken:secret:
|
||||
@brief Designated initializer.
|
||||
@param token The Twitter OAuth token.
|
||||
@param secret The Twitter OAuth secret.
|
||||
*/
|
||||
- (nullable instancetype)initWithToken:(NSString *)token
|
||||
secret:(NSString *)secret NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/AuthProvider/Twitter/FIRTwitterAuthCredential.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/Public/FirebaseAuth/FIRTwitterAuthProvider.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/FIRVerifyAssertionRequest.h"
|
||||
#import "FirebaseAuth/Sources/Utilities/FIRAuthExceptionUtils.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FIRTwitterAuthCredential ()
|
||||
|
||||
- (nullable instancetype)initWithProvider:(NSString *)provider NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FIRTwitterAuthCredential
|
||||
|
||||
- (nullable instancetype)initWithProvider:(NSString *)provider {
|
||||
[FIRAuthExceptionUtils
|
||||
raiseMethodNotImplementedExceptionWithReason:@"Please call the designated initializer."];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithToken:(NSString *)token secret:(NSString *)secret {
|
||||
self = [super initWithProvider:FIRTwitterAuthProviderID];
|
||||
if (self) {
|
||||
_token = [token copy];
|
||||
_secret = [secret copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)prepareVerifyAssertionRequest:(FIRVerifyAssertionRequest *)request {
|
||||
request.providerAccessToken = _token;
|
||||
request.providerOAuthTokenSecret = _secret;
|
||||
}
|
||||
|
||||
#pragma mark - NSSecureCoding
|
||||
|
||||
+ (BOOL)supportsSecureCoding {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder {
|
||||
NSString *token = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"token"];
|
||||
NSString *secret = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"secret"];
|
||||
self = [self initWithToken:token secret:secret];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)aCoder {
|
||||
[aCoder encodeObject:self.token forKey:@"token"];
|
||||
[aCoder encodeObject:self.secret forKey:@"secret"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Public/FirebaseAuth/FIRTwitterAuthProvider.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/AuthProvider/Twitter/FIRTwitterAuthCredential.h"
|
||||
#import "FirebaseAuth/Sources/Utilities/FIRAuthExceptionUtils.h"
|
||||
|
||||
// FIRTwitterAuthProviderID is defined in FIRAuthProvider.m.
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation FIRTwitterAuthProvider
|
||||
|
||||
- (instancetype)init {
|
||||
[FIRAuthExceptionUtils
|
||||
raiseMethodNotImplementedExceptionWithReason:@"This class is not meant to be initialized."];
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (FIRAuthCredential *)credentialWithToken:(NSString *)token secret:(NSString *)secret {
|
||||
return [[FIRTwitterAuthCredential alloc] initWithToken:token secret:secret];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+125
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright 2019 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 <TargetConditionals.h>
|
||||
#if TARGET_OS_IOS
|
||||
|
||||
#import "FirebaseAuth/Sources/Backend/FIRAuthBackend.h"
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/MultiFactor/Enroll/FIRFinalizeMFAEnrollmentRequest.h"
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/MultiFactor/Enroll/FIRFinalizeMFAEnrollmentResponse.h"
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/MultiFactor/Enroll/FIRStartMFAEnrollmentRequest.h"
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/MultiFactor/Enroll/FIRStartMFAEnrollmentResponse.h"
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/MultiFactor/SignIn/FIRFinalizeMFASignInRequest.h"
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/MultiFactor/SignIn/FIRFinalizeMFASignInResponse.h"
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/MultiFactor/SignIn/FIRStartMFASignInRequest.h"
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/MultiFactor/SignIn/FIRStartMFASignInResponse.h"
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/MultiFactor/Unenroll/FIRWithdrawMFARequest.h"
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/MultiFactor/Unenroll/FIRWithdrawMFAResponse.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @typedef FIRStartMFAEnrollmentResponseCallback
|
||||
@brief The type of block used to return the result of a call to the startMFAEnroll endpoint.
|
||||
@param response The received response, if any.
|
||||
@param error The error which occurred, if any.
|
||||
@remarks One of response or error will be non-nil.
|
||||
*/
|
||||
typedef void (^FIRStartMFAEnrollmentResponseCallback)(
|
||||
FIRStartMFAEnrollmentResponse *_Nullable response, NSError *_Nullable error);
|
||||
|
||||
/** @typedef FIRFinalizeMFAEnrollmentResponseCallback
|
||||
@brief The type of block used to return the result of a call to the finalizeMFAEnroll endpoint.
|
||||
@param response The received response, if any.
|
||||
@param error The error which occurred, if any.
|
||||
@remarks One of response or error will be non-nil.
|
||||
*/
|
||||
typedef void (^FIRFinalizeMFAEnrollmentResponseCallback)(
|
||||
FIRFinalizeMFAEnrollmentResponse *_Nullable response, NSError *_Nullable error);
|
||||
|
||||
/** @typedef FIRStartMFASignInResponseCallback
|
||||
@brief The type of block used to return the result of a call to the startMFASignIn endpoint.
|
||||
@param response The received response, if any.
|
||||
@param error The error which occurred, if any.
|
||||
@remarks One of response or error will be non-nil.
|
||||
*/
|
||||
typedef void (^FIRStartMFASignInResponseCallback)(FIRStartMFASignInResponse *_Nullable response,
|
||||
NSError *_Nullable error);
|
||||
|
||||
/** @typedef FIRFinalizeMFASignInResponseCallback
|
||||
@brief The type of block used to return the result of a call to the finalizeMFASignIn endpoint.
|
||||
@param response The received response, if any.
|
||||
@param error The error which occurred, if any.
|
||||
@remarks One of response or error will be non-nil.
|
||||
*/
|
||||
typedef void (^FIRFinalizeMFASignInResponseCallback)(
|
||||
FIRFinalizeMFASignInResponse *_Nullable response, NSError *_Nullable error);
|
||||
|
||||
/** @typedef FIRWithdrawMFAResponseCallback
|
||||
@brief The type of block used to return the result of a call to the MFAUnenroll endpoint.
|
||||
@param response The received response, if any.
|
||||
@param error The error which occurred, if any.
|
||||
@remarks One of response or error will be non-nil.
|
||||
*/
|
||||
typedef void (^FIRWithdrawMFAResponseCallback)(FIRWithdrawMFAResponse *_Nullable response,
|
||||
NSError *_Nullable error);
|
||||
|
||||
@interface FIRAuthBackend (MultiFactor)
|
||||
|
||||
/** @fn startMultiFactorEnrollment:callback:
|
||||
@brief Calls the startMFAEnrollment endpoint.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
+ (void)startMultiFactorEnrollment:(FIRStartMFAEnrollmentRequest *)request
|
||||
callback:(FIRStartMFAEnrollmentResponseCallback)callback;
|
||||
|
||||
/** @fn finalizeMultiFactorEnrollment:callback:
|
||||
@brief Calls the finalizeMultiFactorEnrollment endpoint.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
+ (void)finalizeMultiFactorEnrollment:(FIRFinalizeMFAEnrollmentRequest *)request
|
||||
callback:(FIRFinalizeMFAEnrollmentResponseCallback)callback;
|
||||
|
||||
/** @fn startMultiFactorSignIn:callback:
|
||||
@brief Calls the startMultiFactorSignIn endpoint.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
+ (void)startMultiFactorSignIn:(FIRStartMFASignInRequest *)request
|
||||
callback:(FIRStartMFASignInResponseCallback)callback;
|
||||
|
||||
/** @fn finalizeMultiFactorSignIn:callback:
|
||||
@brief Calls the finalizeMultiFactorSignIn endpoint.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
+ (void)finalizeMultiFactorSignIn:(FIRFinalizeMFASignInRequest *)request
|
||||
callback:(FIRFinalizeMFASignInResponseCallback)callback;
|
||||
|
||||
/** @fn withdrawMultiFactor:callback:
|
||||
@brief Calls the withdrawMultiFactor endpoint.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
+ (void)withdrawMultiFactor:(FIRWithdrawMFARequest *)request
|
||||
callback:(FIRWithdrawMFAResponseCallback)callback;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright 2019 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 <TargetConditionals.h>
|
||||
#if TARGET_OS_IOS
|
||||
|
||||
#import "FirebaseAuth/Sources/Backend/FIRAuthBackend+MultiFactor.h"
|
||||
|
||||
@implementation FIRAuthBackend (MultiFactor)
|
||||
|
||||
+ (void)startMultiFactorEnrollment:(FIRStartMFAEnrollmentRequest *)request
|
||||
callback:(FIRStartMFAEnrollmentResponseCallback)callback {
|
||||
FIRStartMFAEnrollmentResponse *response = [[FIRStartMFAEnrollmentResponse alloc] init];
|
||||
[[self implementation] postWithRequest:request
|
||||
response:response
|
||||
callback:^(NSError *error) {
|
||||
if (error) {
|
||||
callback(nil, error);
|
||||
} else {
|
||||
callback(response, nil);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
+ (void)finalizeMultiFactorEnrollment:(FIRFinalizeMFAEnrollmentRequest *)request
|
||||
callback:(FIRFinalizeMFAEnrollmentResponseCallback)callback {
|
||||
FIRFinalizeMFAEnrollmentResponse *response = [[FIRFinalizeMFAEnrollmentResponse alloc] init];
|
||||
[[self implementation] postWithRequest:request
|
||||
response:response
|
||||
callback:^(NSError *error) {
|
||||
if (error) {
|
||||
callback(nil, error);
|
||||
} else {
|
||||
callback(response, nil);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
+ (void)startMultiFactorSignIn:(FIRStartMFASignInRequest *)request
|
||||
callback:(FIRStartMFASignInResponseCallback)callback {
|
||||
FIRStartMFASignInResponse *response = [[FIRStartMFASignInResponse alloc] init];
|
||||
[[self implementation] postWithRequest:request
|
||||
response:response
|
||||
callback:^(NSError *error) {
|
||||
if (error) {
|
||||
callback(nil, error);
|
||||
} else {
|
||||
callback(response, nil);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
+ (void)finalizeMultiFactorSignIn:(FIRFinalizeMFASignInRequest *)request
|
||||
callback:(FIRFinalizeMFASignInResponseCallback)callback {
|
||||
FIRFinalizeMFASignInResponse *response = [[FIRFinalizeMFASignInResponse alloc] init];
|
||||
[[self implementation] postWithRequest:request
|
||||
response:response
|
||||
callback:^(NSError *error) {
|
||||
if (error) {
|
||||
callback(nil, error);
|
||||
} else {
|
||||
callback(response, nil);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
+ (void)withdrawMultiFactor:(FIRWithdrawMFARequest *)request
|
||||
callback:(FIRWithdrawMFAResponseCallback)callback {
|
||||
FIRWithdrawMFAResponse *response = [[FIRWithdrawMFAResponse alloc] init];
|
||||
[[self implementation] postWithRequest:request
|
||||
response:response
|
||||
callback:^(NSError *error) {
|
||||
if (error) {
|
||||
callback(nil, error);
|
||||
} else {
|
||||
callback(response, nil);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,620 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/FIRAuthRPCRequest.h"
|
||||
#import "FirebaseAuth/Sources/Backend/FIRAuthRPCResponse.h"
|
||||
|
||||
@class FIRAuthRequestConfiguration;
|
||||
@class FIRCreateAuthURIRequest;
|
||||
@class FIRCreateAuthURIResponse;
|
||||
@class FIRDeleteAccountRequest;
|
||||
@class FIRDeleteAccountResponse;
|
||||
@class FIREmailLinkSignInRequest;
|
||||
@class FIREmailLinkSignInResponse;
|
||||
@class FIRGetAccountInfoRequest;
|
||||
@class FIRGetAccountInfoResponse;
|
||||
@class FIRGetProjectConfigRequest;
|
||||
@class FIRGetProjectConfigResponse;
|
||||
@class FIRGetOOBConfirmationCodeRequest;
|
||||
@class FIRGetOOBConfirmationCodeResponse;
|
||||
@class FIRResetPasswordRequest;
|
||||
@class FIRResetPasswordResponse;
|
||||
@class FIRSecureTokenRequest;
|
||||
@class FIRSecureTokenResponse;
|
||||
@class FIRSetAccountInfoRequest;
|
||||
@class FIRSetAccountInfoResponse;
|
||||
@class FIRVerifyAssertionRequest;
|
||||
@class FIRVerifyAssertionResponse;
|
||||
@class FIRVerifyClientRequest;
|
||||
@class FIRVerifyClientResponse;
|
||||
@class FIRVerifyCustomTokenRequest;
|
||||
@class FIRVerifyCustomTokenResponse;
|
||||
@class FIRVerifyPasswordRequest;
|
||||
@class FIRVerifyPasswordResponse;
|
||||
@class FIRVerifyPhoneNumberRequest;
|
||||
@class FIRVerifyPhoneNumberResponse;
|
||||
@class FIRSendVerificationCodeRequest;
|
||||
@class FIRSendVerificationCodeResponse;
|
||||
@class FIRSignInWithGameCenterRequest;
|
||||
@class FIRSignInWithGameCenterResponse;
|
||||
@class FIRSignUpNewUserRequest;
|
||||
@class FIRSignUpNewUserResponse;
|
||||
|
||||
@protocol FIRAuthBackendImplementation;
|
||||
@protocol FIRAuthBackendRPCIssuer;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @typedef FIRAuthBackendRPCIssuerCompletionHandler
|
||||
@brief The type of block used to return the result of a call to an endpoint.
|
||||
@param data The HTTP response body.
|
||||
@param error The error which occurred, if any.
|
||||
@remarks One of response or error will be non-nil.
|
||||
*/
|
||||
typedef void (^FIRAuthBackendRPCIssuerCompletionHandler)(NSData *_Nullable data,
|
||||
NSError *_Nullable error);
|
||||
|
||||
/** @typedef FIRCreateAuthURIResponseCallback
|
||||
@brief The type of block used to return the result of a call to the createAuthURI
|
||||
endpoint.
|
||||
@param response The received response, if any.
|
||||
@param error The error which occurred, if any.
|
||||
@remarks One of response or error will be non-nil.
|
||||
*/
|
||||
typedef void (^FIRCreateAuthURIResponseCallback)(FIRCreateAuthURIResponse *_Nullable response,
|
||||
NSError *_Nullable error);
|
||||
|
||||
/** @typedef FIRGetAccountInfoResponseCallback
|
||||
@brief The type of block used to return the result of a call to the getAccountInfo
|
||||
endpoint.
|
||||
@param response The received response, if any.
|
||||
@param error The error which occurred, if any.
|
||||
@remarks One of response or error will be non-nil.
|
||||
*/
|
||||
typedef void (^FIRGetAccountInfoResponseCallback)(FIRGetAccountInfoResponse *_Nullable response,
|
||||
NSError *_Nullable error);
|
||||
|
||||
/** @typedef FIRGetProjectConfigResponseCallback
|
||||
@brief The type of block used to return the result of a call to the getProjectInfo
|
||||
endpoint.
|
||||
@param response The received response, if any.
|
||||
@param error The error which occurred, if any.
|
||||
@remarks One of response or error will be non-nil.
|
||||
*/
|
||||
typedef void (^FIRGetProjectConfigResponseCallback)(FIRGetProjectConfigResponse *_Nullable response,
|
||||
NSError *_Nullable error);
|
||||
|
||||
/** @typedef FIRSetAccountInfoResponseCallback
|
||||
@brief The type of block used to return the result of a call to the setAccountInfo
|
||||
endpoint.
|
||||
@param response The received response, if any.
|
||||
@param error The error which occurred, if any.
|
||||
@remarks One of response or error will be non-nil.
|
||||
*/
|
||||
typedef void (^FIRSetAccountInfoResponseCallback)(FIRSetAccountInfoResponse *_Nullable response,
|
||||
NSError *_Nullable error);
|
||||
|
||||
/** @typedef FIRSecureTokenResponseCallback
|
||||
@brief The type of block used to return the result of a call to the token endpoint.
|
||||
@param response The received response, if any.
|
||||
@param error The error which occurred, if any.
|
||||
@remarks One of response or error will be non-nil.
|
||||
*/
|
||||
typedef void (^FIRSecureTokenResponseCallback)(FIRSecureTokenResponse *_Nullable response,
|
||||
NSError *_Nullable error);
|
||||
|
||||
/** @typedef FIRVerifyAssertionResponseCallback
|
||||
@brief The type of block used to return the result of a call to the verifyAssertion
|
||||
endpoint.
|
||||
@param response The received response, if any.
|
||||
@param error The error which occurred, if any.
|
||||
@remarks One of response or error will be non-nil.
|
||||
*/
|
||||
typedef void (^FIRVerifyAssertionResponseCallback)(FIRVerifyAssertionResponse *_Nullable response,
|
||||
NSError *_Nullable error);
|
||||
|
||||
/** @typedef FIRVerifyPasswordResponseCallback
|
||||
@brief The type of block used to return the result of a call to the verifyPassword
|
||||
endpoint.
|
||||
@param response The received response, if any.
|
||||
@param error The error which occurred, if any.
|
||||
@remarks One of response or error will be non-nil.
|
||||
*/
|
||||
typedef void (^FIRVerifyPasswordResponseCallback)(FIRVerifyPasswordResponse *_Nullable response,
|
||||
NSError *_Nullable error);
|
||||
|
||||
/** @typedef FIREmailLinkSigninResponseCallback
|
||||
@brief The type of block used to return the result of a call to the emailLinkSignin
|
||||
endpoint.
|
||||
@param response The received response, if any.
|
||||
@param error The error which occurred, if any.
|
||||
@remarks One of response or error will be non-nil.
|
||||
*/
|
||||
typedef void (^FIREmailLinkSigninResponseCallback)(FIREmailLinkSignInResponse *_Nullable response,
|
||||
NSError *_Nullable error);
|
||||
|
||||
/** @typedef FIRVerifyCustomTokenResponseCallback
|
||||
@brief The type of block used to return the result of a call to the verifyCustomToken
|
||||
endpoint.
|
||||
@param response The received response, if any.
|
||||
@param error The error which occurred, if any.
|
||||
@remarks One of response or error will be non-nil.
|
||||
*/
|
||||
typedef void (^FIRVerifyCustomTokenResponseCallback)(
|
||||
FIRVerifyCustomTokenResponse *_Nullable response, NSError *_Nullable error);
|
||||
|
||||
/** @typedef FIRDeleteCallBack
|
||||
@brief The type of block called when a request delete account has finished.
|
||||
@param error The error which occurred, or nil if the request was successful.
|
||||
*/
|
||||
typedef void (^FIRDeleteCallBack)(NSError *_Nullable error);
|
||||
|
||||
/** @typedef FIRGetOOBConfirmationCodeResponseCallback
|
||||
@brief The type of block used to return the result of a call to the getOOBConfirmationCode
|
||||
endpoint.
|
||||
@param response The received response, if any.
|
||||
@param error The error which occurred, if any.
|
||||
@remarks One of response or error will be non-nil.
|
||||
*/
|
||||
typedef void (^FIRGetOOBConfirmationCodeResponseCallback)(
|
||||
FIRGetOOBConfirmationCodeResponse *_Nullable response, NSError *_Nullable error);
|
||||
|
||||
/** @typedef FIRSignupNewUserCallback
|
||||
@brief The type of block used to return the result of a call to the signupNewUser endpoint.
|
||||
@param response The received response, if any.
|
||||
@param error The error which occurred, if any.
|
||||
@remarks One of response or error will be non-nil.
|
||||
*/
|
||||
typedef void (^FIRSignupNewUserCallback)(FIRSignUpNewUserResponse *_Nullable response,
|
||||
NSError *_Nullable error);
|
||||
|
||||
/** @typedef FIRResetPasswordCallback
|
||||
@brief The type of block used to return the result of a call to the resetPassword endpoint.
|
||||
@param response The received response, if any.
|
||||
@param error The error which occurred, if any.
|
||||
@remarks One of response or error will be non-nil.
|
||||
*/
|
||||
typedef void (^FIRResetPasswordCallback)(FIRResetPasswordResponse *_Nullable response,
|
||||
NSError *_Nullable error);
|
||||
|
||||
/** @typedef FIRSendVerificationCodeResponseCallback
|
||||
@brief The type of block used to return the result of a call to the sendVerificationCode
|
||||
endpoint.
|
||||
@param response The received response, if any.
|
||||
@param error The error which occurred, if any.
|
||||
@remarks One of response or error will be non-nil.
|
||||
*/
|
||||
typedef void (^FIRSendVerificationCodeResponseCallback)(
|
||||
FIRSendVerificationCodeResponse *_Nullable response, NSError *_Nullable error);
|
||||
|
||||
/** @typedef FIRVerifyPhoneNumberResponseCallback
|
||||
@brief The type of block used to return the result of a call to the verifyPhoneNumber endpoint.
|
||||
@param response The received response, if any.
|
||||
@param error The error which occurred, if any.
|
||||
@remarks One of response or error will be non-nil.
|
||||
*/
|
||||
typedef void (^FIRVerifyPhoneNumberResponseCallback)(
|
||||
FIRVerifyPhoneNumberResponse *_Nullable response, NSError *_Nullable error);
|
||||
|
||||
/** @typedef FIRVerifyClientResponseCallback
|
||||
@brief The type of block used to return the result of a call to the verifyClient endpoint.
|
||||
@param response The received response, if any.
|
||||
@param error The error which occurred, if any.
|
||||
@remarks One of response or error will be non-nil.
|
||||
*/
|
||||
typedef void (^FIRVerifyClientResponseCallback)(FIRVerifyClientResponse *_Nullable response,
|
||||
NSError *_Nullable error);
|
||||
|
||||
/** @typedef FIRSignInWithGameCenterResponseCallback
|
||||
@brief The type of block used to return the result of a call to the SignInWithGameCenter
|
||||
endpoint.
|
||||
@param response The received response, if any.
|
||||
@param error The error which occurred, if any.
|
||||
@remarks One of response or error will be non-nil.
|
||||
*/
|
||||
typedef void (^FIRSignInWithGameCenterResponseCallback)(
|
||||
FIRSignInWithGameCenterResponse *_Nullable response, NSError *_Nullable error);
|
||||
|
||||
/** @class FIRAuthBackend
|
||||
@brief Simple static class with methods representing the backend RPCs.
|
||||
@remarks All callback blocks passed as method parameters are invoked asynchronously on the
|
||||
global work queue in the future. See
|
||||
https://github.com/firebase/firebase-ios-sdk/tree/master/FirebaseAuth/Docs/threading.md
|
||||
*/
|
||||
@interface FIRAuthBackend : NSObject
|
||||
|
||||
/** @fn authUserAgent
|
||||
@brief Retrieves the Firebase Auth user agent.
|
||||
@return The Firebase Auth user agent.
|
||||
*/
|
||||
+ (NSString *)authUserAgent;
|
||||
|
||||
+ (id<FIRAuthBackendImplementation>)implementation;
|
||||
|
||||
/** @fn setBackendImplementation:
|
||||
@brief Changes the default backend implementation to something else.
|
||||
@param backendImplementation The backend implementation to use.
|
||||
@remarks This is not, generally, safe to call in a scenario where other backend requests may
|
||||
be occuring. This is specifically to help mock the backend for testing purposes.
|
||||
*/
|
||||
+ (void)setBackendImplementation:(id<FIRAuthBackendImplementation>)backendImplementation;
|
||||
|
||||
/** @fn setDefaultBackendImplementationWithRPCIssuer:
|
||||
@brief Uses the default backend implementation, but with a custom RPC issuer.
|
||||
@param RPCIssuer The RPC issuer to use. If @c nil, will use the default implementation.
|
||||
@remarks This is not, generally, safe to call in a scenario where other backend requests may
|
||||
be occuring. This is specifically to help test the backend interfaces (requests, responses,
|
||||
and shared FIRAuthBackend logic.)
|
||||
*/
|
||||
+ (void)setDefaultBackendImplementationWithRPCIssuer:
|
||||
(nullable id<FIRAuthBackendRPCIssuer>)RPCIssuer;
|
||||
|
||||
/** @fn createAuthURI:callback:
|
||||
@brief Calls the createAuthURI endpoint, which is responsible for creating the URI used by the
|
||||
IdP to authenticate the user.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
+ (void)createAuthURI:(FIRCreateAuthURIRequest *)request
|
||||
callback:(FIRCreateAuthURIResponseCallback)callback;
|
||||
|
||||
/** @fn getAccountInfo:callback:
|
||||
@brief Calls the getAccountInfo endpoint, which returns account info for a given account.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
+ (void)getAccountInfo:(FIRGetAccountInfoRequest *)request
|
||||
callback:(FIRGetAccountInfoResponseCallback)callback;
|
||||
|
||||
/** @fn getProjectConfig:callback:
|
||||
@brief Calls the getProjectConfig endpoint, which returns configuration information for a given
|
||||
project.
|
||||
@param request An object wrapping the backend get request.
|
||||
@param callback The callback.
|
||||
*/
|
||||
+ (void)getProjectConfig:(FIRGetProjectConfigRequest *)request
|
||||
callback:(FIRGetProjectConfigResponseCallback)callback;
|
||||
|
||||
/** @fn setAccountInfo:callback:
|
||||
@brief Calls the setAccountInfo endpoint, which is responsible for setting account info for a
|
||||
user, for example, to sign up a new user with email and password.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
+ (void)setAccountInfo:(FIRSetAccountInfoRequest *)request
|
||||
callback:(FIRSetAccountInfoResponseCallback)callback;
|
||||
|
||||
/** @fn verifyAssertion:callback:
|
||||
@brief Calls the verifyAssertion endpoint, which is responsible for authenticating a
|
||||
user who has IDP-related credentials (an ID Token, an Access Token, etc.)
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
+ (void)verifyAssertion:(FIRVerifyAssertionRequest *)request
|
||||
callback:(FIRVerifyAssertionResponseCallback)callback;
|
||||
|
||||
/** @fn verifyCustomToken:callback:
|
||||
@brief Calls the verifyCustomToken endpoint, which is responsible for authenticating a
|
||||
user who has BYOAuth credentials (a self-signed token using their BYOAuth private key.)
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
+ (void)verifyCustomToken:(FIRVerifyCustomTokenRequest *)request
|
||||
callback:(FIRVerifyCustomTokenResponseCallback)callback;
|
||||
|
||||
/** @fn verifyPassword:callback:
|
||||
@brief Calls the verifyPassword endpoint, which is responsible for authenticating a
|
||||
user who has email and password credentials.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
+ (void)verifyPassword:(FIRVerifyPasswordRequest *)request
|
||||
callback:(FIRVerifyPasswordResponseCallback)callback;
|
||||
|
||||
/** @fn emailLinkSignin:callback:
|
||||
@brief Calls the emailLinkSignin endpoint, which is responsible for authenticating a
|
||||
user through passwordless sign-in.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
+ (void)emailLinkSignin:(FIREmailLinkSignInRequest *)request
|
||||
callback:(FIREmailLinkSigninResponseCallback)callback;
|
||||
|
||||
/** @fn secureToken:callback:
|
||||
@brief Calls the token endpoint, which is responsible for performing STS token exchanges and
|
||||
token refreshes.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
+ (void)secureToken:(FIRSecureTokenRequest *)request
|
||||
callback:(FIRSecureTokenResponseCallback)callback;
|
||||
|
||||
/** @fn getOOBConfirmationCode:callback:
|
||||
@brief Calls the getOOBConfirmationCode endpoint, which is responsible for sending email change
|
||||
request emails, and password reset emails.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
+ (void)getOOBConfirmationCode:(FIRGetOOBConfirmationCodeRequest *)request
|
||||
callback:(FIRGetOOBConfirmationCodeResponseCallback)callback;
|
||||
|
||||
/** @fn signUpNewUser:
|
||||
@brief Calls the signUpNewUser endpoint, which is responsible anonymously signing up a user
|
||||
or signing in a user anonymously.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
+ (void)signUpNewUser:(FIRSignUpNewUserRequest *)request
|
||||
callback:(FIRSignupNewUserCallback)callback;
|
||||
|
||||
/** @fn resetPassword:callback
|
||||
@brief Calls the resetPassword endpoint, which is responsible for resetting a user's password
|
||||
given an OOB code and new password.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
+ (void)resetPassword:(FIRResetPasswordRequest *)request
|
||||
callback:(FIRResetPasswordCallback)callback;
|
||||
|
||||
/** @fn deleteAccount:
|
||||
@brief Calls the DeleteAccount endpoint, which is responsible for deleting a user.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
+ (void)deleteAccount:(FIRDeleteAccountRequest *)request callback:(FIRDeleteCallBack)callback;
|
||||
|
||||
/** @fn SignInWithGameCenter:callback:
|
||||
@brief Calls the SignInWithGameCenter endpoint, which is responsible for authenticating a user
|
||||
who has Game Center credentials.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
+ (void)signInWithGameCenter:(FIRSignInWithGameCenterRequest *)request
|
||||
callback:(FIRSignInWithGameCenterResponseCallback)callback;
|
||||
|
||||
#if TARGET_OS_IOS
|
||||
/** @fn sendVerificationCode:callback:
|
||||
@brief Calls the sendVerificationCode endpoint, which is responsible for sending the
|
||||
verification code to a phone number specified in the request parameters.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
+ (void)sendVerificationCode:(FIRSendVerificationCodeRequest *)request
|
||||
callback:(FIRSendVerificationCodeResponseCallback)callback;
|
||||
|
||||
/** @fn verifyPhoneNumber:callback:
|
||||
@brief Calls the verifyPhoneNumber endpoint, which is responsible for sending the verification
|
||||
code to a phone number specified in the request parameters.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
+ (void)verifyPhoneNumber:(FIRVerifyPhoneNumberRequest *)request
|
||||
callback:(FIRVerifyPhoneNumberResponseCallback)callback;
|
||||
|
||||
/** @fn verifyClient:callback:
|
||||
@brief Calls the verifyClient endpoint, which is responsible for sending the silent push
|
||||
notification used for app validation to the device provided in the request parameters.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
+ (void)verifyClient:(FIRVerifyClientRequest *)request
|
||||
callback:(FIRVerifyClientResponseCallback)callback;
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
/** @protocol FIRAuthBackendRPCIssuer
|
||||
@brief Used to make FIRAuthBackend
|
||||
*/
|
||||
@protocol FIRAuthBackendRPCIssuer <NSObject>
|
||||
|
||||
/** @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)asyncPostToURLWithRequestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
|
||||
URL:(NSURL *)URL
|
||||
body:(nullable NSData *)body
|
||||
contentType:(NSString *)contentType
|
||||
completionHandler:(FIRAuthBackendRPCIssuerCompletionHandler)handler;
|
||||
|
||||
@end
|
||||
|
||||
/** @protocol FIRAuthBackendImplementation
|
||||
@brief Used to make FIRAuthBackend provide a layer of indirection to an actual RPC-based backend
|
||||
or a mock backend.
|
||||
*/
|
||||
@protocol FIRAuthBackendImplementation <NSObject>
|
||||
|
||||
/** @fn createAuthURI:callback:
|
||||
@brief Calls the createAuthURI endpoint, which is responsible for creating the URI used by the
|
||||
IdP to authenticate the user.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
- (void)createAuthURI:(FIRCreateAuthURIRequest *)request
|
||||
callback:(FIRCreateAuthURIResponseCallback)callback;
|
||||
|
||||
/** @fn getAccountInfo:callback:
|
||||
@brief Calls the getAccountInfo endpoint, which returns account info for a given account.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
- (void)getAccountInfo:(FIRGetAccountInfoRequest *)request
|
||||
callback:(FIRGetAccountInfoResponseCallback)callback;
|
||||
|
||||
/** @fn getProjectConfig:callback:
|
||||
@brief Calls the getProjectInfo endpoint, which returns configuration information for a given
|
||||
project.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
- (void)getProjectConfig:(FIRGetProjectConfigRequest *)request
|
||||
callback:(FIRGetProjectConfigResponseCallback)callback;
|
||||
|
||||
/** @fn setAccountInfo:callback:
|
||||
@brief Calls the setAccountInfo endpoint, which is responsible for setting account info for a
|
||||
user, for example, to sign up a new user with email and password.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
- (void)setAccountInfo:(FIRSetAccountInfoRequest *)request
|
||||
callback:(FIRSetAccountInfoResponseCallback)callback;
|
||||
|
||||
/** @fn verifyAssertion:callback:
|
||||
@brief Calls the verifyAssertion endpoint, which is responsible for authenticating a
|
||||
user who has IDP-related credentials (an ID Token, an Access Token, etc.)
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
- (void)verifyAssertion:(FIRVerifyAssertionRequest *)request
|
||||
callback:(FIRVerifyAssertionResponseCallback)callback;
|
||||
|
||||
/** @fn verifyCustomToken:callback:
|
||||
@brief Calls the verifyCustomToken endpoint, which is responsible for authenticating a
|
||||
user who has BYOAuth credentials (a self-signed token using their BYOAuth private key.)
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
- (void)verifyCustomToken:(FIRVerifyCustomTokenRequest *)request
|
||||
callback:(FIRVerifyCustomTokenResponseCallback)callback;
|
||||
|
||||
/** @fn verifyPassword:callback:
|
||||
@brief Calls the verifyPassword endpoint, which is responsible for authenticating a
|
||||
user who has email and password credentials.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
- (void)verifyPassword:(FIRVerifyPasswordRequest *)request
|
||||
callback:(FIRVerifyPasswordResponseCallback)callback;
|
||||
|
||||
/** @fn emailLinkSignin:callback:
|
||||
@brief Calls the emailLinkSignin endpoint, which is responsible for authenticating a
|
||||
user through passwordless sign-in.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
- (void)emailLinkSignin:(FIREmailLinkSignInRequest *)request
|
||||
callback:(FIREmailLinkSigninResponseCallback)callback;
|
||||
|
||||
/** @fn secureToken:callback:
|
||||
@brief Calls the token endpoint, which is responsible for performing STS token exchanges and
|
||||
token refreshes.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
- (void)secureToken:(FIRSecureTokenRequest *)request
|
||||
callback:(FIRSecureTokenResponseCallback)callback;
|
||||
|
||||
/** @fn getOOBConfirmationCode:callback:
|
||||
@brief Calls the getOOBConfirmationCode endpoint, which is responsible for sending email change
|
||||
request emails, email sign-in link emails, and password reset emails.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
- (void)getOOBConfirmationCode:(FIRGetOOBConfirmationCodeRequest *)request
|
||||
callback:(FIRGetOOBConfirmationCodeResponseCallback)callback;
|
||||
|
||||
/** @fn signUpNewUser:
|
||||
@brief Calls the signUpNewUser endpoint, which is responsible anonymously signing up a user
|
||||
or signing in a user anonymously.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
- (void)signUpNewUser:(FIRSignUpNewUserRequest *)request
|
||||
callback:(FIRSignupNewUserCallback)callback;
|
||||
|
||||
/** @fn deleteAccount:
|
||||
@brief Calls the DeleteAccount endpoint, which is responsible for deleting a user.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
- (void)deleteAccount:(FIRDeleteAccountRequest *)request callback:(FIRDeleteCallBack)callback;
|
||||
|
||||
#if TARGET_OS_IOS
|
||||
/** @fn sendVerificationCode:callback:
|
||||
@brief Calls the sendVerificationCode endpoint, which is responsible for sending the
|
||||
verification code to a phone number specified in the request parameters.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
- (void)sendVerificationCode:(FIRSendVerificationCodeRequest *)request
|
||||
callback:(FIRSendVerificationCodeResponseCallback)callback;
|
||||
|
||||
/** @fn verifyPhoneNumber:callback:
|
||||
@brief Calls the verifyPhoneNumber endpoint, which is responsible for sending the verification
|
||||
code to a phone number specified in the request parameters.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
- (void)verifyPhoneNumber:(FIRVerifyPhoneNumberRequest *)request
|
||||
callback:(FIRVerifyPhoneNumberResponseCallback)callback;
|
||||
|
||||
/** @fn verifyClient:callback:
|
||||
@brief Calls the verifyClient endpoint, which is responsible for sending the silent push
|
||||
notification used for app validation to the device provided in the request parameters.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
- (void)verifyClient:(FIRVerifyClientRequest *)request
|
||||
callback:(FIRVerifyClientResponseCallback)callback;
|
||||
#endif
|
||||
|
||||
/** @fn SignInWithGameCenter:callback:
|
||||
@brief Calls the SignInWithGameCenter endpoint, which is responsible for authenticating a user
|
||||
who has Game Center credentials.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
- (void)signInWithGameCenter:(FIRSignInWithGameCenterRequest *)request
|
||||
callback:(FIRSignInWithGameCenterResponseCallback)callback;
|
||||
|
||||
/** @fn resetPassword:callback
|
||||
@brief Calls the resetPassword endpoint, which is responsible for resetting a user's password
|
||||
given an OOB code and new password.
|
||||
@param request The request parameters.
|
||||
@param callback The callback.
|
||||
*/
|
||||
- (void)resetPassword:(FIRResetPasswordRequest *)request
|
||||
callback:(FIRResetPasswordCallback)callback;
|
||||
|
||||
/** @fn postWithRequest:response:callback:
|
||||
@brief Calls the RPC using HTTP POST.
|
||||
@remarks Possible error responses:
|
||||
@see FIRAuthInternalErrorCodeRPCRequestEncodingError
|
||||
@see FIRAuthInternalErrorCodeJSONSerializationError
|
||||
@see FIRAuthInternalErrorCodeNetworkError
|
||||
@see FIRAuthInternalErrorCodeUnexpectedErrorResponse
|
||||
@see FIRAuthInternalErrorCodeUnexpectedResponse
|
||||
@see FIRAuthInternalErrorCodeRPCResponseDecodingError
|
||||
@param request The request.
|
||||
@param response The empty response to be filled.
|
||||
@param callback The callback for both success and failure.
|
||||
*/
|
||||
- (void)postWithRequest:(id<FIRAuthRPCRequest>)request
|
||||
response:(id<FIRAuthRPCResponse>)response
|
||||
callback:(void (^)(NSError *_Nullable error))callback;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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>
|
||||
|
||||
@class FIRAuthRequestConfiguration;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @protocol FIRAuthRPCRequest
|
||||
@brief The generic interface for an RPC request needed by @c FIRAuthBackend.
|
||||
*/
|
||||
@protocol FIRAuthRPCRequest <NSObject>
|
||||
|
||||
/** @fn requestURL
|
||||
@brief Gets the request's full URL.
|
||||
*/
|
||||
- (NSURL *)requestURL;
|
||||
|
||||
@optional
|
||||
|
||||
/** @fn containsPostBody
|
||||
@brief Returns whether the request contains a post body or not. Requests without a post body
|
||||
are get requests.
|
||||
@remarks The default implementation returns YES.
|
||||
*/
|
||||
- (BOOL)containsPostBody;
|
||||
|
||||
/** @fn UnencodedHTTPRequestBodyWithError:
|
||||
@brief Creates unencoded HTTP body representing the request.
|
||||
@param error An out field for an error which occurred constructing the request.
|
||||
@return The HTTP body data representing the request before any encoding, or nil for error.
|
||||
*/
|
||||
- (nullable id)unencodedHTTPRequestBodyWithError:(NSError *_Nullable *_Nullable)error;
|
||||
|
||||
/** @fn requestConfiguration
|
||||
@brief Obtains the request configurations if available.
|
||||
@return Returns the request configurations.
|
||||
*/
|
||||
- (FIRAuthRequestConfiguration *)requestConfiguration;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @protocol FIRAuthRPCResponse
|
||||
@brief The generic interface for an RPC response needed by @c FIRAuthBackend.
|
||||
*/
|
||||
@protocol FIRAuthRPCResponse <NSObject>
|
||||
|
||||
/** @fn setFieldsWithDictionary:error:
|
||||
@brief Sets the response instance from the decoded JSON response.
|
||||
@param dictionary The dictionary decoded from HTTP JSON response.
|
||||
@param error An out field for an error which occurred constructing the request.
|
||||
@return Whether the operation was successful or not.
|
||||
*/
|
||||
- (BOOL)setWithDictionary:(NSDictionary *)dictionary error:(NSError *_Nullable *_Nullable)error;
|
||||
|
||||
@optional
|
||||
|
||||
/** @fn clientErrorWithshortErrorMessage:detailErrorMessage
|
||||
@brief This optional method allows response classes to create client errors given a short error
|
||||
message and a detail error message from the server.
|
||||
@param shortErrorMessage The short error message from the server.
|
||||
@param detailErrorMessage The detailed error message from the server.
|
||||
@return A client error, if any.
|
||||
*/
|
||||
- (nullable NSError *)clientErrorWithShortErrorMessage:(NSString *)shortErrorMessage
|
||||
detailErrorMessage:(nullable NSString *)detailErrorMessage;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/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;
|
||||
|
||||
/** @property additionalFrameworkMarker
|
||||
@brief Additional framework marker that will be added as part of the header of every request.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSString *additionalFrameworkMarker;
|
||||
|
||||
/** @property emulatorHostAndPort
|
||||
@brief If set, the local emulator host and port to point to instead of the remote backend.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSString *emulatorHostAndPort;
|
||||
|
||||
- (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
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/FIRAuthRequestConfiguration.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/Utilities/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
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/FIRAuthRequestConfiguration.h"
|
||||
|
||||
@class FIRAuthRequestConfiguration;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @class FIRIdentityToolkitRequest
|
||||
@brief Represents a request to an identity toolkit endpoint.
|
||||
*/
|
||||
@interface FIRIdentityToolkitRequest : NSObject
|
||||
|
||||
/** @property endpoint
|
||||
@brief Gets the RPC's endpoint.
|
||||
*/
|
||||
@property(nonatomic, copy, readonly) NSString *endpoint;
|
||||
|
||||
/** @property APIKey
|
||||
@brief Gets the client's API key used for the request.
|
||||
*/
|
||||
@property(nonatomic, copy, readonly) NSString *APIKey;
|
||||
|
||||
/** @property tenantID
|
||||
@brief The tenant ID of the request. nil if none is available.
|
||||
*/
|
||||
@property(nonatomic, copy, readonly, nullable) NSString *tenantID;
|
||||
|
||||
/** @fn init
|
||||
@brief Please use initWithEndpoint:APIKey:
|
||||
*/
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
/** @fn initWithEndpoint:APIKey:
|
||||
@brief Designated initializer.
|
||||
@param endpoint The endpoint name.
|
||||
@param requestConfiguration An object containing configurations to be added to the request.
|
||||
*/
|
||||
- (nullable instancetype)initWithEndpoint:(NSString *)endpoint
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
|
||||
NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
- (nullable instancetype)initWithEndpoint:(NSString *)endpoint
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
|
||||
useIdentityPlatform:(BOOL)useIdentityPlatform
|
||||
useStaging:(BOOL)useStaging;
|
||||
|
||||
/** @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
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/FIRIdentityToolkitRequest.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/Public/FirebaseAuth/FIRAuth.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
static NSString *const kHttpsProtocol = @"https:";
|
||||
static NSString *const kHttpProtocol = @"http:";
|
||||
|
||||
static NSString *const kFirebaseAuthAPIURLFormat =
|
||||
@"%@//%@/identitytoolkit/v3/relyingparty/%@?key=%@";
|
||||
static NSString *const kIdentityPlatformAPIURLFormat = @"%@//%@/v2/%@?key=%@";
|
||||
static NSString *const kEmulatorHostAndPrefixFormat = @"%@/%@";
|
||||
|
||||
static NSString *gAPIHost = @"www.googleapis.com";
|
||||
|
||||
static NSString *kFirebaseAuthAPIHost = @"www.googleapis.com";
|
||||
static NSString *kIdentityPlatformAPIHost = @"identitytoolkit.googleapis.com";
|
||||
|
||||
static NSString *kFirebaseAuthStagingAPIHost = @"staging-www.sandbox.googleapis.com";
|
||||
static NSString *kIdentityPlatformStagingAPIHost =
|
||||
@"staging-identitytoolkit.sandbox.googleapis.com";
|
||||
|
||||
@implementation FIRIdentityToolkitRequest {
|
||||
FIRAuthRequestConfiguration *_requestConfiguration;
|
||||
|
||||
BOOL _useIdentityPlatform;
|
||||
|
||||
BOOL _useStaging;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithEndpoint:(NSString *)endpoint
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_APIKey = [requestConfiguration.APIKey copy];
|
||||
_endpoint = [endpoint copy];
|
||||
_requestConfiguration = requestConfiguration;
|
||||
_useIdentityPlatform = NO;
|
||||
_useStaging = NO;
|
||||
|
||||
// Automatically set the tenant ID. If the request is initialized before FIRAuth is configured,
|
||||
// set tenant ID to nil.
|
||||
@try {
|
||||
_tenantID = [FIRAuth auth].tenantID;
|
||||
} @catch (NSException *e) {
|
||||
_tenantID = nil;
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithEndpoint:(NSString *)endpoint
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
|
||||
useIdentityPlatform:(BOOL)useIdentityPlatform
|
||||
useStaging:(BOOL)useStaging {
|
||||
self = [self initWithEndpoint:endpoint requestConfiguration:requestConfiguration];
|
||||
if (self) {
|
||||
_useIdentityPlatform = useIdentityPlatform;
|
||||
_useStaging = useStaging;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)containsPostBody {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSURL *)requestURL {
|
||||
NSString *apiURLFormat;
|
||||
NSString *apiProtocol;
|
||||
NSString *apiHostAndPathPrefix;
|
||||
|
||||
NSString *emulatorHostAndPort = _requestConfiguration.emulatorHostAndPort;
|
||||
|
||||
if (_useIdentityPlatform) {
|
||||
apiURLFormat = kIdentityPlatformAPIURLFormat;
|
||||
apiProtocol = kHttpsProtocol;
|
||||
if (emulatorHostAndPort) {
|
||||
apiProtocol = kHttpProtocol;
|
||||
apiHostAndPathPrefix =
|
||||
[NSString stringWithFormat:kEmulatorHostAndPrefixFormat, emulatorHostAndPort,
|
||||
kIdentityPlatformAPIHost];
|
||||
} else if (_useStaging) {
|
||||
apiHostAndPathPrefix = kIdentityPlatformStagingAPIHost;
|
||||
} else {
|
||||
apiHostAndPathPrefix = kIdentityPlatformAPIHost;
|
||||
}
|
||||
} else {
|
||||
apiURLFormat = kFirebaseAuthAPIURLFormat;
|
||||
apiProtocol = kHttpsProtocol;
|
||||
if (emulatorHostAndPort) {
|
||||
apiProtocol = kHttpProtocol;
|
||||
apiHostAndPathPrefix = [NSString
|
||||
stringWithFormat:kEmulatorHostAndPrefixFormat, emulatorHostAndPort, kFirebaseAuthAPIHost];
|
||||
} else if (_useStaging) {
|
||||
apiHostAndPathPrefix = kFirebaseAuthStagingAPIHost;
|
||||
} else {
|
||||
apiHostAndPathPrefix = kFirebaseAuthAPIHost;
|
||||
}
|
||||
}
|
||||
NSString *URLString = [NSString
|
||||
stringWithFormat:apiURLFormat, apiProtocol, apiHostAndPathPrefix, _endpoint, _APIKey];
|
||||
NSURL *URL = [NSURL URLWithString:URLString];
|
||||
return URL;
|
||||
}
|
||||
|
||||
- (FIRAuthRequestConfiguration *)requestConfiguration {
|
||||
return _requestConfiguration;
|
||||
}
|
||||
|
||||
#pragma mark - Internal API for development
|
||||
|
||||
+ (NSString *)host {
|
||||
return gAPIHost;
|
||||
}
|
||||
|
||||
+ (void)setHost:(NSString *)host {
|
||||
gAPIHost = host;
|
||||
}
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@end
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/FIRAuthRPCRequest.h"
|
||||
#import "FirebaseAuth/Sources/Backend/FIRIdentityToolkitRequest.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @class FIRCreateAuthURIRequest
|
||||
@brief Represents the parameters for the createAuthUri endpoint.
|
||||
@see https://developers.google.com/identity/toolkit/web/reference/relyingparty/createAuthUri
|
||||
*/
|
||||
@interface FIRCreateAuthURIRequest : FIRIdentityToolkitRequest <FIRAuthRPCRequest>
|
||||
|
||||
/** @property identifier
|
||||
@brief The email or federated ID of the user.
|
||||
*/
|
||||
@property(nonatomic, copy) NSString *identifier;
|
||||
|
||||
/** @property continueURI
|
||||
@brief The URI to which the IDP redirects the user after the federated login flow.
|
||||
*/
|
||||
@property(nonatomic, copy) NSString *continueURI;
|
||||
|
||||
/** @property openIDRealm
|
||||
@brief Optional realm for OpenID protocol. The sub string "scheme://domain:port" of the param
|
||||
"continueUri" is used if this is not set.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSString *openIDRealm;
|
||||
|
||||
/** @property providerID
|
||||
@brief The IdP ID. For white listed IdPs it's a short domain name e.g. google.com, aol.com,
|
||||
live.net and yahoo.com. For other OpenID IdPs it's the OP identifier.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSString *providerID;
|
||||
|
||||
/** @property clientID
|
||||
@brief The relying party OAuth client ID.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSString *clientID;
|
||||
|
||||
/** @property context
|
||||
@brief The opaque value used by the client to maintain context info between the authentication
|
||||
request and the IDP callback.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSString *context;
|
||||
|
||||
/** @property appID
|
||||
@brief The iOS client application's bundle identifier.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSString *appID;
|
||||
|
||||
/** @fn initWithEndpoint:requestConfiguration:requestConfiguration.
|
||||
@brief Please use initWithIdentifier:continueURI:requestConfiguration: instead.
|
||||
*/
|
||||
- (nullable instancetype)initWithEndpoint:(NSString *)endpoint
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
|
||||
NS_UNAVAILABLE;
|
||||
|
||||
/** @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 requestConfiguration An object containing configurations to be added to the request.
|
||||
*/
|
||||
- (nullable instancetype)initWithIdentifier:(NSString *)identifier
|
||||
continueURI:(NSString *)continueURI
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
|
||||
NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/RPC/FIRCreateAuthURIRequest.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @var kCreateAuthURIEndpoint
|
||||
@brief The "createAuthUri" endpoint.
|
||||
*/
|
||||
static NSString *const kCreateAuthURIEndpoint = @"createAuthUri";
|
||||
|
||||
/** @var kProviderIDKey
|
||||
@brief The key for the "providerId" value in the request.
|
||||
*/
|
||||
static NSString *const kProviderIDKey = @"providerId";
|
||||
|
||||
/** @var kIdentifierKey
|
||||
@brief The key for the "identifier" value in the request.
|
||||
*/
|
||||
static NSString *const kIdentifierKey = @"identifier";
|
||||
|
||||
/** @var kContinueURIKey
|
||||
@brief The key for the "continueUri" value in the request.
|
||||
*/
|
||||
static NSString *const kContinueURIKey = @"continueUri";
|
||||
|
||||
/** @var kOpenIDRealmKey
|
||||
@brief The key for the "openidRealm" value in the request.
|
||||
*/
|
||||
static NSString *const kOpenIDRealmKey = @"openidRealm";
|
||||
|
||||
/** @var kClientIDKey
|
||||
@brief The key for the "clientId" value in the request.
|
||||
*/
|
||||
static NSString *const kClientIDKey = @"clientId";
|
||||
|
||||
/** @var kContextKey
|
||||
@brief The key for the "context" value in the request.
|
||||
*/
|
||||
static NSString *const kContextKey = @"context";
|
||||
|
||||
/** @var kAppIDKey
|
||||
@brief The key for the "appId" value in the request.
|
||||
*/
|
||||
static NSString *const kAppIDKey = @"appId";
|
||||
|
||||
/** @var kTenantIDKey
|
||||
@brief The key for the tenant id value in the request.
|
||||
*/
|
||||
static NSString *const kTenantIDKey = @"tenantId";
|
||||
|
||||
@implementation FIRCreateAuthURIRequest
|
||||
|
||||
- (nullable instancetype)initWithIdentifier:(NSString *)identifier
|
||||
continueURI:(NSString *)continueURI
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration {
|
||||
self = [super initWithEndpoint:kCreateAuthURIEndpoint requestConfiguration:requestConfiguration];
|
||||
if (self) {
|
||||
_identifier = [identifier copy];
|
||||
_continueURI = [continueURI copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (nullable id)unencodedHTTPRequestBodyWithError:(NSError *_Nullable *_Nullable)error {
|
||||
NSMutableDictionary *postBody =
|
||||
[@{kIdentifierKey : _identifier, kContinueURIKey : _continueURI} mutableCopy];
|
||||
if (_providerID) {
|
||||
postBody[kProviderIDKey] = _providerID;
|
||||
}
|
||||
if (_openIDRealm) {
|
||||
postBody[kOpenIDRealmKey] = _openIDRealm;
|
||||
}
|
||||
if (_clientID) {
|
||||
postBody[kClientIDKey] = _clientID;
|
||||
}
|
||||
if (_context) {
|
||||
postBody[kContextKey] = _context;
|
||||
}
|
||||
if (_appID) {
|
||||
postBody[kAppIDKey] = _appID;
|
||||
}
|
||||
if (self.tenantID) {
|
||||
postBody[kTenantIDKey] = self.tenantID;
|
||||
}
|
||||
return [postBody copy];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/FIRAuthRPCResponse.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @class FIRCreateAuthURIResponse
|
||||
@brief Represents the parameters for the createAuthUri endpoint.
|
||||
@see https://developers.google.com/identity/toolkit/web/reference/relyingparty/createAuthUri
|
||||
*/
|
||||
@interface FIRCreateAuthURIResponse : NSObject <FIRAuthRPCResponse>
|
||||
|
||||
/** @property authUri
|
||||
@brief The URI used by the IDP to authenticate the user.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSString *authURI;
|
||||
|
||||
/** @property registered
|
||||
@brief Whether the user is registered if the identifier is an email.
|
||||
*/
|
||||
@property(nonatomic, assign, readonly) BOOL registered;
|
||||
|
||||
/** @property providerId
|
||||
@brief The provider ID of the auth URI.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSString *providerID;
|
||||
|
||||
/** @property forExistingProvider
|
||||
@brief True if the authUri is for user's existing provider.
|
||||
*/
|
||||
@property(nonatomic, assign, readonly) BOOL forExistingProvider;
|
||||
|
||||
/** @property allProviders
|
||||
@brief A list of provider IDs the passed @c identifier could use to sign in with.
|
||||
*/
|
||||
@property(nonatomic, copy, readonly, nullable) NSArray<NSString *> *allProviders;
|
||||
|
||||
/** @property signinMethods
|
||||
@brief A list of sign-in methods available for the passed @c identifier.
|
||||
*/
|
||||
@property(nonatomic, copy, readonly, nullable) NSArray<NSString *> *signinMethods;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/RPC/FIRCreateAuthURIResponse.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation FIRCreateAuthURIResponse
|
||||
|
||||
- (BOOL)setWithDictionary:(NSDictionary *)dictionary error:(NSError *_Nullable *_Nullable)error {
|
||||
_providerID = [dictionary[@"providerId"] copy];
|
||||
_authURI = [dictionary[@"authUri"] copy];
|
||||
_registered = [dictionary[@"registered"] boolValue];
|
||||
_forExistingProvider = [dictionary[@"forExistingProvider"] boolValue];
|
||||
_allProviders = [dictionary[@"allProviders"] copy];
|
||||
_signinMethods = [dictionary[@"signinMethods"] copy];
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/FIRAuthRPCRequest.h"
|
||||
#import "FirebaseAuth/Sources/Backend/FIRIdentityToolkitRequest.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @class FIRDeleteAccountRequest
|
||||
@brief Represents the parameters for the deleteAccount endpoint.
|
||||
@see https://developers.google.com/identity/toolkit/web/reference/relyingparty/deleteAccount
|
||||
*/
|
||||
@interface FIRDeleteAccountRequest : FIRIdentityToolkitRequest <FIRAuthRPCRequest>
|
||||
|
||||
/** @fn initWithEndpoint:requestConfiguration:requestConfiguration.
|
||||
@brief Please use initWitLocalID:accessToken:requestConfiguration instead.
|
||||
*/
|
||||
- (nullable instancetype)initWithEndpoint:(NSString *)endpoint
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
|
||||
NS_UNAVAILABLE;
|
||||
|
||||
/** @fn initWitLocalID:accessToken:requestConfiguration.
|
||||
@brief Designated initializer.
|
||||
@param localID The local ID.
|
||||
@param accessToken The access token.
|
||||
@param requestConfiguration An object containing configurations to be added to the request.
|
||||
*/
|
||||
- (nullable instancetype)initWitLocalID:(NSString *)localID
|
||||
accessToken:(NSString *)accessToken
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
|
||||
NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/RPC/FIRDeleteAccountRequest.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @var kCreateAuthURIEndpoint
|
||||
@brief The "deleteAccount" endpoint.
|
||||
*/
|
||||
static NSString *const kDeleteAccountEndpoint = @"deleteAccount";
|
||||
|
||||
/** @var kIDTokenKey
|
||||
@brief The key for the "idToken" value in the request. This is actually the STS Access Token,
|
||||
despite it's confusing (backwards compatiable) parameter name.
|
||||
*/
|
||||
static NSString *const kIDTokenKey = @"idToken";
|
||||
|
||||
/** @var kLocalIDKey
|
||||
@brief The key for the "localID" value in the request.
|
||||
*/
|
||||
static NSString *const kLocalIDKey = @"localId";
|
||||
|
||||
@implementation FIRDeleteAccountRequest {
|
||||
/** @var _accessToken
|
||||
@brief The STS Access Token of the authenticated user.
|
||||
*/
|
||||
NSString *_accessToken;
|
||||
|
||||
/** @var _localID
|
||||
@brief The localID of the user.
|
||||
*/
|
||||
NSString *_localID;
|
||||
}
|
||||
|
||||
- (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];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (nullable id)unencodedHTTPRequestBodyWithError:(NSError *_Nullable *_Nullable)error {
|
||||
NSMutableDictionary *postBody = [NSMutableDictionary dictionary];
|
||||
postBody[kIDTokenKey] = _accessToken;
|
||||
postBody[kLocalIDKey] = _localID;
|
||||
return [postBody copy];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/FIRAuthRPCResponse.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @class FIRDeleteAccountResponse
|
||||
@brief Represents the response from the deleteAccount endpoint.
|
||||
@see https://developers.google.com/identity/toolkit/web/reference/relyingparty/deleteAccount
|
||||
*/
|
||||
@interface FIRDeleteAccountResponse : NSObject <FIRAuthRPCResponse>
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/RPC/FIRDeleteAccountResponse.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation FIRDeleteAccountResponse
|
||||
|
||||
- (BOOL)setWithDictionary:(NSDictionary *)dictionary error:(NSError *_Nullable *_Nullable)error {
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/FIRAuthRPCRequest.h"
|
||||
#import "FirebaseAuth/Sources/Backend/FIRIdentityToolkitRequest.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @class FIREmailLinkSignInRequest
|
||||
@brief Represents the parameters for the emailLinkSignin endpoint.
|
||||
*/
|
||||
@interface FIREmailLinkSignInRequest : FIRIdentityToolkitRequest <FIRAuthRPCRequest>
|
||||
|
||||
#pragma mark - Components of "postBody"
|
||||
|
||||
/** @property email
|
||||
@brief The email identifier used to complete the email link sign-in.
|
||||
*/
|
||||
@property(nonatomic, copy, readonly) NSString *email;
|
||||
|
||||
/** @property oobCode
|
||||
@brief The OOB code used to complete the email link sign-in flow.
|
||||
*/
|
||||
@property(nonatomic, copy, readonly) NSString *oobCode;
|
||||
|
||||
/** @property IDToken
|
||||
@brief The ID Token code potentially used to complete the email link sign-in flow.
|
||||
*/
|
||||
@property(nonatomic, copy) NSString *IDToken;
|
||||
|
||||
/** @fn initWithEndpoint:requestConfiguration:
|
||||
@brief Please use initWithProviderID:requestConfifuration instead.
|
||||
*/
|
||||
- (instancetype)initWithEndpoint:(NSString *)endpoint
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration NS_UNAVAILABLE;
|
||||
|
||||
/** @fn initWithProviderID:requestConfifuration
|
||||
@brief Designated initializer.
|
||||
@param email The email identifier used to complete hte email link sign-in flow.
|
||||
@param oobCode The OOB code used to complete the email link sign-in flow.
|
||||
@param requestConfiguration An object containing configurations to be added to the request.
|
||||
|
||||
*/
|
||||
- (instancetype)initWithEmail:(NSString *)email
|
||||
oobCode:(NSString *)oobCode
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
|
||||
NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/RPC/FIREmailLinkSignInRequest.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @var kEmailLinkSigninEndpoint
|
||||
@brief The "EmailLinkSignin" endpoint.
|
||||
*/
|
||||
static NSString *const kEmailLinkSigninEndpoint = @"emailLinkSignin";
|
||||
|
||||
/** @var kEmailKey
|
||||
@brief The key for the "identifier" value in the request.
|
||||
*/
|
||||
static NSString *const kEmailKey = @"email";
|
||||
|
||||
/** @var kEmailLinkKey
|
||||
@brief The key for the "emailLink" value in the request.
|
||||
*/
|
||||
static NSString *const kOOBCodeKey = @"oobCode";
|
||||
|
||||
/** @var kIDTokenKey
|
||||
@brief The key for the "IDToken" value in the request.
|
||||
*/
|
||||
static NSString *const kIDTokenKey = @"idToken";
|
||||
|
||||
/** @var kPostBodyKey
|
||||
@brief The key for the "postBody" value in the request.
|
||||
*/
|
||||
static NSString *const kPostBodyKey = @"postBody";
|
||||
|
||||
/** @var kTenantIDKey
|
||||
@brief The key for the tenant id value in the request.
|
||||
*/
|
||||
static NSString *const kTenantIDKey = @"tenantId";
|
||||
|
||||
@implementation FIREmailLinkSignInRequest
|
||||
|
||||
- (instancetype)initWithEmail:(NSString *)email
|
||||
oobCode:(NSString *)oobCode
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration {
|
||||
self = [super initWithEndpoint:kEmailLinkSigninEndpoint
|
||||
requestConfiguration:requestConfiguration];
|
||||
if (self) {
|
||||
_email = email;
|
||||
_oobCode = oobCode;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (nullable id)unencodedHTTPRequestBodyWithError:(NSError *_Nullable *_Nullable)error {
|
||||
NSMutableDictionary *postBody = [@{
|
||||
kEmailKey : _email,
|
||||
kOOBCodeKey : _oobCode,
|
||||
} mutableCopy];
|
||||
|
||||
if (_IDToken) {
|
||||
postBody[kIDTokenKey] = _IDToken;
|
||||
}
|
||||
if (self.tenantID) {
|
||||
postBody[kTenantIDKey] = self.tenantID;
|
||||
}
|
||||
return [postBody copy];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/FIRAuthRPCResponse.h"
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/Proto/FIRAuthProtoMFAEnrollment.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @class FIRVerifyAssertionResponse
|
||||
@brief Represents the response from the emailLinkSignin endpoint.
|
||||
*/
|
||||
@interface FIREmailLinkSignInResponse : NSObject <FIRAuthRPCResponse>
|
||||
|
||||
/** @property IDToken
|
||||
@brief The ID token in the email link sign-in response.
|
||||
*/
|
||||
@property(nonatomic, copy, readonly) NSString *IDToken;
|
||||
|
||||
/** @property email
|
||||
@brief The email returned by the IdP.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSString *email;
|
||||
|
||||
/** @property refreshToken
|
||||
@brief The refreshToken returned by the server.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSString *refreshToken;
|
||||
|
||||
/** @property localID
|
||||
@brief The Firebase Auth user ID.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSString *localID;
|
||||
|
||||
/** @property approximateExpirationDate
|
||||
@brief The approximate expiration date of the access token.
|
||||
*/
|
||||
@property(nonatomic, copy, readonly, nullable) NSDate *approximateExpirationDate;
|
||||
|
||||
/** @property isNewUser
|
||||
@brief Flag indicating that the user signing in is a new user and not a returning user.
|
||||
*/
|
||||
@property(nonatomic, assign) BOOL isNewUser;
|
||||
|
||||
/** @property MFAPendingCredential
|
||||
@brief An opaque string that functions as proof that the user has successfully passed the first
|
||||
factor check.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSString *MFAPendingCredential;
|
||||
|
||||
/** @property MFAInfo
|
||||
@brief Info on which multi-factor authentication providers are enabled.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSArray<FIRAuthProtoMFAEnrollment *> *MFAInfo;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/RPC/FIREmailLinkSignInResponse.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation FIREmailLinkSignInResponse
|
||||
|
||||
- (BOOL)setWithDictionary:(NSDictionary *)dictionary error:(NSError *_Nullable *_Nullable)error {
|
||||
_localID = [dictionary[@"localId"] copy];
|
||||
_email = [dictionary[@"email"] copy];
|
||||
_IDToken = [dictionary[@"idToken"] copy];
|
||||
_isNewUser = [dictionary[@"isNewUser"] boolValue];
|
||||
_refreshToken = [dictionary[@"refreshToken"] copy];
|
||||
_approximateExpirationDate =
|
||||
[dictionary[@"expiresIn"] isKindOfClass:[NSString class]]
|
||||
? [NSDate dateWithTimeIntervalSinceNow:[dictionary[@"expiresIn"] doubleValue]]
|
||||
: nil;
|
||||
if (dictionary[@"mfaInfo"] != nil) {
|
||||
NSMutableArray<FIRAuthProtoMFAEnrollment *> *MFAInfo = [NSMutableArray array];
|
||||
NSArray *MFAInfoDataArray = dictionary[@"mfaInfo"];
|
||||
for (NSDictionary *MFAInfoData in MFAInfoDataArray) {
|
||||
FIRAuthProtoMFAEnrollment *MFAEnrollment =
|
||||
[[FIRAuthProtoMFAEnrollment alloc] initWithDictionary:MFAInfoData];
|
||||
[MFAInfo addObject:MFAEnrollment];
|
||||
}
|
||||
_MFAInfo = MFAInfo;
|
||||
}
|
||||
_MFAPendingCredential = [dictionary[@"mfaPendingCredential"] copy];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/FIRAuthRPCRequest.h"
|
||||
#import "FirebaseAuth/Sources/Backend/FIRIdentityToolkitRequest.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @class FIRGetAccountInfoRequest
|
||||
@brief Represents the parameters for the getAccountInfo endpoint.
|
||||
@see https://developers.google.com/identity/toolkit/web/reference/relyingparty/getAccountInfo
|
||||
*/
|
||||
@interface FIRGetAccountInfoRequest : FIRIdentityToolkitRequest <FIRAuthRPCRequest>
|
||||
|
||||
/** @property accessToken
|
||||
@brief The STS Access Token for the authenticated user.
|
||||
*/
|
||||
@property(nonatomic, copy) NSString *accessToken;
|
||||
|
||||
/** @fn initWithEndpoint:requestConfiguration:requestConfiguration
|
||||
@brief Please use initWithAccessToken:requestConfiguration: instead.
|
||||
*/
|
||||
- (nullable instancetype)initWithEndpoint:(NSString *)endpoint
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
|
||||
NS_UNAVAILABLE;
|
||||
|
||||
/** @fn initWithAccessToken:requestConfiguration
|
||||
@brief Designated initializer.
|
||||
@param accessToken The Access Token of the authenticated user.
|
||||
@param requestConfiguration An object containing configurations to be added to the request.
|
||||
*/
|
||||
- (nullable instancetype)initWithAccessToken:(NSString *)accessToken
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
|
||||
NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/RPC/FIRGetAccountInfoRequest.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @var kGetAccountInfoEndpoint
|
||||
@brief The "getAccountInfo" endpoint.
|
||||
*/
|
||||
static NSString *const kGetAccountInfoEndpoint = @"getAccountInfo";
|
||||
|
||||
/** @var kIDTokenKey
|
||||
@brief The key for the "idToken" value in the request. This is actually the STS Access Token,
|
||||
despite it's confusing (backwards compatiable) parameter name.
|
||||
*/
|
||||
static NSString *const kIDTokenKey = @"idToken";
|
||||
|
||||
@implementation FIRGetAccountInfoRequest
|
||||
|
||||
- (nullable instancetype)initWithAccessToken:(NSString *)accessToken
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration {
|
||||
self = [super initWithEndpoint:kGetAccountInfoEndpoint requestConfiguration:requestConfiguration];
|
||||
if (self) {
|
||||
_accessToken = [accessToken copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (nullable id)unencodedHTTPRequestBodyWithError:(NSError *_Nullable *_Nullable)error {
|
||||
return @{kIDTokenKey : _accessToken};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/FIRAuthRPCResponse.h"
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/Proto/FIRAuthProtoMFAEnrollment.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @class FIRGetAccountInfoResponseProviderUserInfo
|
||||
@brief Represents the provider user info part of the response from the getAccountInfo endpoint.
|
||||
@see https://developers.google.com/identity/toolkit/web/reference/relyingparty/getAccountInfo
|
||||
*/
|
||||
@interface FIRGetAccountInfoResponseProviderUserInfo : NSObject
|
||||
|
||||
/** @property providerID
|
||||
@brief The ID of the identity provider.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSString *providerID;
|
||||
|
||||
/** @property displayName
|
||||
@brief The user's display name at the identity provider.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSString *displayName;
|
||||
|
||||
/** @property photoURL
|
||||
@brief The user's photo URL at the identity provider.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSURL *photoURL;
|
||||
|
||||
/** @property federatedID
|
||||
@brief The user's identifier at the identity provider.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSString *federatedID;
|
||||
|
||||
/** @property email
|
||||
@brief The user's email at the identity provider.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSString *email;
|
||||
|
||||
/** @property phoneNumber
|
||||
@brief A phone number associated with the user.
|
||||
*/
|
||||
@property(nonatomic, readonly, nullable) NSString *phoneNumber;
|
||||
|
||||
/** @fn init
|
||||
@brief Please use initWithDictionary:
|
||||
*/
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
/** @fn initWithAPIKey:
|
||||
@brief Designated initializer.
|
||||
@param dictionary The provider user info data from endpoint.
|
||||
*/
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dictionary NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@end
|
||||
|
||||
/** @class FIRGetAccountInfoResponseUser
|
||||
@brief Represents the firebase user info part of the response from the getAccountInfo endpoint.
|
||||
@see https://developers.google.com/identity/toolkit/web/reference/relyingparty/getAccountInfo
|
||||
*/
|
||||
@interface FIRGetAccountInfoResponseUser : NSObject
|
||||
|
||||
/** @property localID
|
||||
@brief The ID of the user.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSString *localID;
|
||||
|
||||
/** @property email
|
||||
@brief The email or the user.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSString *email;
|
||||
|
||||
/** @property emailVerified
|
||||
@brief Whether the email has been verified.
|
||||
*/
|
||||
@property(nonatomic, assign, readonly) BOOL emailVerified;
|
||||
|
||||
/** @property displayName
|
||||
@brief The display name of the user.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSString *displayName;
|
||||
|
||||
/** @property photoURL
|
||||
@brief The user's photo URL.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSURL *photoURL;
|
||||
|
||||
/** @property creationDate
|
||||
@brief The user's creation date.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSDate *creationDate;
|
||||
|
||||
/** @property lastSignInDate
|
||||
@brief The user's last login date.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSDate *lastLoginDate;
|
||||
|
||||
/** @property providerUserInfo
|
||||
@brief The user's profiles at the associated identity providers.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable)
|
||||
NSArray<FIRGetAccountInfoResponseProviderUserInfo *> *providerUserInfo;
|
||||
|
||||
/** @property passwordHash
|
||||
@brief Information about user's password.
|
||||
@remarks This is not necessarily the hash of user's actual password.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSString *passwordHash;
|
||||
|
||||
/** @property phoneNumber
|
||||
@brief A phone number associated with the user.
|
||||
*/
|
||||
@property(nonatomic, readonly, nullable) NSString *phoneNumber;
|
||||
|
||||
@property(nonatomic, strong, readonly, nullable)
|
||||
NSArray<FIRAuthProtoMFAEnrollment *> *MFAEnrollments;
|
||||
|
||||
/** @fn init
|
||||
@brief Please use initWithDictionary:
|
||||
*/
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
/** @fn initWithAPIKey:
|
||||
@brief Designated initializer.
|
||||
@param dictionary The provider user info data from endpoint.
|
||||
*/
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dictionary NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@end
|
||||
|
||||
/** @class FIRGetAccountInfoResponse
|
||||
@brief Represents the response from the setAccountInfo endpoint.
|
||||
@see https://developers.google.com/identity/toolkit/web/reference/relyingparty/getAccountInfo
|
||||
*/
|
||||
@interface FIRGetAccountInfoResponse : NSObject <FIRAuthRPCResponse>
|
||||
|
||||
/** @property providerUserInfo
|
||||
@brief The requested users' profiles.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSArray<FIRGetAccountInfoResponseUser *> *users;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/RPC/FIRGetAccountInfoResponse.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/Utilities/FIRAuthErrorUtils.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @var kErrorKey
|
||||
@brief The key for the "error" value in JSON responses from the server.
|
||||
*/
|
||||
static NSString *const kErrorKey = @"error";
|
||||
|
||||
@implementation FIRGetAccountInfoResponseProviderUserInfo
|
||||
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dictionary {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_providerID = [dictionary[@"providerId"] copy];
|
||||
_displayName = [dictionary[@"displayName"] copy];
|
||||
NSString *photoURL = dictionary[@"photoUrl"];
|
||||
if (photoURL) {
|
||||
_photoURL = [NSURL URLWithString:photoURL];
|
||||
}
|
||||
_federatedID = [dictionary[@"federatedId"] copy];
|
||||
_email = [dictionary[@"email"] copy];
|
||||
_phoneNumber = [dictionary[@"phoneNumber"] copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation FIRGetAccountInfoResponseUser
|
||||
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dictionary {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
NSArray<NSDictionary *> *providerUserInfoData = dictionary[@"providerUserInfo"];
|
||||
if (providerUserInfoData) {
|
||||
NSMutableArray<FIRGetAccountInfoResponseProviderUserInfo *> *providerUserInfoArray =
|
||||
[NSMutableArray arrayWithCapacity:providerUserInfoData.count];
|
||||
for (NSDictionary *dictionary in providerUserInfoData) {
|
||||
[providerUserInfoArray addObject:[[FIRGetAccountInfoResponseProviderUserInfo alloc]
|
||||
initWithDictionary:dictionary]];
|
||||
}
|
||||
_providerUserInfo = [providerUserInfoArray copy];
|
||||
}
|
||||
_localID = [dictionary[@"localId"] copy];
|
||||
_displayName = [dictionary[@"displayName"] copy];
|
||||
_email = [dictionary[@"email"] copy];
|
||||
NSString *photoURL = dictionary[@"photoUrl"];
|
||||
if (photoURL) {
|
||||
_photoURL = [NSURL URLWithString:photoURL];
|
||||
}
|
||||
if ([dictionary[@"createdAt"] isKindOfClass:[NSString class]]) {
|
||||
// Divide by 1000 in order to convert miliseconds to seconds.
|
||||
NSTimeInterval creationDateTimeInterval = [dictionary[@"createdAt"] doubleValue] / 1000;
|
||||
_creationDate = [NSDate dateWithTimeIntervalSince1970:creationDateTimeInterval];
|
||||
}
|
||||
if ([dictionary[@"lastLoginAt"] isKindOfClass:[NSString class]]) {
|
||||
// Divide by 1000 in order to convert miliseconds to seconds
|
||||
NSTimeInterval creationDateTimeInterval = [dictionary[@"lastLoginAt"] doubleValue] / 1000;
|
||||
_lastLoginDate = [NSDate dateWithTimeIntervalSince1970:creationDateTimeInterval];
|
||||
}
|
||||
_emailVerified = [dictionary[@"emailVerified"] boolValue];
|
||||
_passwordHash = [dictionary[@"passwordHash"] copy];
|
||||
_phoneNumber = [dictionary[@"phoneNumber"] copy];
|
||||
NSArray<NSDictionary *> *MFAEnrollmentData = dictionary[@"mfaInfo"];
|
||||
if (MFAEnrollmentData) {
|
||||
NSMutableArray<FIRAuthProtoMFAEnrollment *> *MFAEnrollments =
|
||||
[NSMutableArray arrayWithCapacity:MFAEnrollmentData.count];
|
||||
for (NSDictionary *dictionary in MFAEnrollmentData) {
|
||||
[MFAEnrollments
|
||||
addObject:[[FIRAuthProtoMFAEnrollment alloc] initWithDictionary:dictionary]];
|
||||
}
|
||||
_MFAEnrollments = [MFAEnrollments copy];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation FIRGetAccountInfoResponse
|
||||
|
||||
- (BOOL)setWithDictionary:(NSDictionary *)dictionary error:(NSError *_Nullable *_Nullable)error {
|
||||
NSArray<NSDictionary *> *usersData = dictionary[@"users"];
|
||||
// The client side never sends a getAccountInfo request with multiple localID, so only one user
|
||||
// data is expected in the response.
|
||||
if (![usersData isKindOfClass:[NSArray class]] || usersData.count != 1) {
|
||||
if (error) {
|
||||
*error = [FIRAuthErrorUtils unexpectedResponseWithDeserializedResponse:dictionary];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
_users = @[ [[FIRGetAccountInfoResponseUser alloc] initWithDictionary:usersData.firstObject] ];
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+178
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/FIRAuthRPCRequest.h"
|
||||
#import "FirebaseAuth/Sources/Backend/FIRIdentityToolkitRequest.h"
|
||||
|
||||
@class FIRActionCodeSettings;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @enum FIRGetOOBConfirmationCodeRequestType
|
||||
@brief Types of OOB Confirmation Code requests.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, FIRGetOOBConfirmationCodeRequestType) {
|
||||
/** @var FIRGetOOBConfirmationCodeRequestTypePasswordReset
|
||||
@brief Requests a password reset code.
|
||||
*/
|
||||
FIRGetOOBConfirmationCodeRequestTypePasswordReset,
|
||||
|
||||
/** @var FIRGetOOBConfirmationCodeRequestTypeVerifyEmail
|
||||
@brief Requests an email verification code.
|
||||
*/
|
||||
FIRGetOOBConfirmationCodeRequestTypeVerifyEmail,
|
||||
|
||||
/** @var FIRGetOOBConfirmationCodeRequestTypeEmailLink
|
||||
@brief Requests an email sign-in link.
|
||||
*/
|
||||
FIRGetOOBConfirmationCodeRequestTypeEmailLink,
|
||||
|
||||
/** @var FIRGetOOBConfirmationCodeRequestTypeVerifyBeforeUpdateEmail
|
||||
@brief Requests an verify before update email.
|
||||
*/
|
||||
FIRGetOOBConfirmationCodeRequestTypeVerifyBeforeUpdateEmail,
|
||||
};
|
||||
|
||||
/** @enum FIRGetOOBConfirmationCodeRequest
|
||||
@brief Represents the parameters for the getOOBConfirmationCode endpoint.
|
||||
*/
|
||||
@interface FIRGetOOBConfirmationCodeRequest : FIRIdentityToolkitRequest <FIRAuthRPCRequest>
|
||||
|
||||
/** @property requestType
|
||||
@brief The types of OOB Confirmation Code to request.
|
||||
*/
|
||||
@property(nonatomic, assign, readonly) FIRGetOOBConfirmationCodeRequestType requestType;
|
||||
|
||||
/** @property email
|
||||
@brief The email of the user.
|
||||
@remarks For password reset.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable, readonly) NSString *email;
|
||||
|
||||
/** @property updatedEmail
|
||||
@brief The new email to be updated.
|
||||
@remarks For verifyBeforeUpdateEmail.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable, readonly) NSString *updatedEmail;
|
||||
|
||||
/** @property accessToken
|
||||
@brief The STS Access Token of the authenticated user.
|
||||
@remarks For email change.
|
||||
*/
|
||||
@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 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 dynamicLinkDomain
|
||||
@brief The Firebase Dynamic Link domain used for out of band code flow.
|
||||
*/
|
||||
@property(copy, nonatomic, nullable) NSString *dynamicLinkDomain;
|
||||
|
||||
/** @fn passwordResetRequestWithEmail:actionCodeSettings:requestConfiguration:
|
||||
@brief Creates a password reset request.
|
||||
@param email The user's email address.
|
||||
@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
|
||||
actionCodeSettings:(nullable FIRActionCodeSettings *)actionCodeSettings
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration;
|
||||
|
||||
/** @fn verifyEmailRequestWithAccessToken:actionCodeSettings:requestConfiguration:
|
||||
@brief Creates a password reset request.
|
||||
@param accessToken The user's STS Access Token.
|
||||
@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
|
||||
actionCodeSettings:(nullable FIRActionCodeSettings *)actionCodeSettings
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration;
|
||||
|
||||
/** @fn signInWithEmailLinkRequest:actionCodeSettings:requestConfiguration:
|
||||
@brief Creates a sign-in with email link.
|
||||
@param email The user's email address.
|
||||
@param actionCodeSettings An object of FIRActionCodeSettings which specifies action code
|
||||
settings to be applied to the email sign-in link.
|
||||
@param requestConfiguration An object containing configurations to be added to the request.
|
||||
@return An email sign-in link request.
|
||||
*/
|
||||
+ (nullable FIRGetOOBConfirmationCodeRequest *)
|
||||
signInWithEmailLinkRequest:(NSString *)email
|
||||
actionCodeSettings:(nullable FIRActionCodeSettings *)actionCodeSettings
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration;
|
||||
|
||||
/** @fn verifyBeforeUpdateEmailWithAccessToken:newEmail:actionCodeSettings:requestConfiguration:
|
||||
@brief Creates a verifyBeforeUpdateEmail request.
|
||||
@param accessToken The user's STS Access Token.
|
||||
@param newEmail The user's email address to be updated.
|
||||
@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 verifyBeforeUpdateEmail request.
|
||||
*/
|
||||
+ (nullable FIRGetOOBConfirmationCodeRequest *)
|
||||
verifyBeforeUpdateEmailWithAccessToken:(NSString *)accessToken
|
||||
newEmail:(NSString *)newEmail
|
||||
actionCodeSettings:(nullable FIRActionCodeSettings *)actionCodeSettings
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration;
|
||||
|
||||
/** @fn init
|
||||
@brief Please use a factory method.
|
||||
*/
|
||||
- (nullable instancetype)initWithEndpoint:(NSString *)endpoint
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
|
||||
NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+296
@@ -0,0 +1,296 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/RPC/FIRGetOOBConfirmationCodeRequest.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/Public/FirebaseAuth/FIRActionCodeSettings.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/Auth/FIRAuth_Internal.h"
|
||||
#import "FirebaseAuth/Sources/Utilities/FIRAuthErrorUtils.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @var kEndpoint
|
||||
@brief The getOobConfirmationCode endpoint name.
|
||||
*/
|
||||
static NSString *const kGetOobConfirmationCodeEndpoint = @"getOobConfirmationCode";
|
||||
|
||||
/** @var kRequestTypeKey
|
||||
@brief The name of the required "requestType" property in the request.
|
||||
*/
|
||||
static NSString *const kRequestTypeKey = @"requestType";
|
||||
|
||||
/** @var kEmailKey
|
||||
@brief The name of the "email" property in the request.
|
||||
*/
|
||||
static NSString *const kEmailKey = @"email";
|
||||
|
||||
/** @var kNewEmailKey
|
||||
@brief The name of the "newEmail" property in the request.
|
||||
*/
|
||||
static NSString *const kNewEmailKey = @"newEmail";
|
||||
|
||||
/** @var kIDTokenKey
|
||||
@brief The key for the "idToken" value in the request. This is actually the STS Access Token,
|
||||
despite it's confusing (backwards compatiable) parameter name.
|
||||
*/
|
||||
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 kDynamicLinkDomainKey
|
||||
@brief The key for the "dynamic link domain" value in the request.
|
||||
*/
|
||||
static NSString *const kDynamicLinkDomainKey = @"dynamicLinkDomain";
|
||||
|
||||
/** @var kPasswordResetRequestTypeValue
|
||||
@brief The value for the "PASSWORD_RESET" request type.
|
||||
*/
|
||||
static NSString *const kPasswordResetRequestTypeValue = @"PASSWORD_RESET";
|
||||
|
||||
/** @var kEmailLinkSignInTypeValue
|
||||
@brief The value for the "EMAIL_SIGNIN" request type.
|
||||
*/
|
||||
static NSString *const kEmailLinkSignInTypeValue = @"EMAIL_SIGNIN";
|
||||
|
||||
/** @var kVerifyEmailRequestTypeValue
|
||||
@brief The value for the "VERIFY_EMAIL" request type.
|
||||
*/
|
||||
static NSString *const kVerifyEmailRequestTypeValue = @"VERIFY_EMAIL";
|
||||
|
||||
/** @var kVerifyBeforeUpdateEmailRequestTypeValue
|
||||
@brief The value for the "VERIFY_AND_CHANGE_EMAIL" request type.
|
||||
*/
|
||||
static NSString *const kVerifyBeforeUpdateEmailRequestTypeValue = @"VERIFY_AND_CHANGE_EMAIL";
|
||||
|
||||
/** @var kTenantIDKey
|
||||
@brief The key for the tenant id value in the request.
|
||||
*/
|
||||
static NSString *const kTenantIDKey = @"tenantId";
|
||||
|
||||
@interface FIRGetOOBConfirmationCodeRequest ()
|
||||
|
||||
/** @fn initWithRequestType:email:APIKey:
|
||||
@brief Designated initializer.
|
||||
@param requestType The types of OOB Confirmation Code to request.
|
||||
@param email The email of the user.
|
||||
@param newEmail The email of the user to be updated.
|
||||
@param accessToken The STS Access Token of the currently signed in user.
|
||||
@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
|
||||
newEmail:(nullable NSString *)newEmail
|
||||
accessToken:(nullable NSString *)accessToken
|
||||
actionCodeSettings:(nullable FIRActionCodeSettings *)actionCodeSettings
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
|
||||
NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FIRGetOOBConfirmationCodeRequest
|
||||
|
||||
/** @var requestTypeStringValueForRequestType:
|
||||
@brief Returns the string equivilent for an @c FIRGetOOBConfirmationCodeRequestType value.
|
||||
*/
|
||||
+ (NSString *)requestTypeStringValueForRequestType:
|
||||
(FIRGetOOBConfirmationCodeRequestType)requestType {
|
||||
switch (requestType) {
|
||||
case FIRGetOOBConfirmationCodeRequestTypePasswordReset:
|
||||
return kPasswordResetRequestTypeValue;
|
||||
case FIRGetOOBConfirmationCodeRequestTypeVerifyEmail:
|
||||
return kVerifyEmailRequestTypeValue;
|
||||
case FIRGetOOBConfirmationCodeRequestTypeEmailLink:
|
||||
return kEmailLinkSignInTypeValue;
|
||||
case FIRGetOOBConfirmationCodeRequestTypeVerifyBeforeUpdateEmail:
|
||||
return kVerifyBeforeUpdateEmailRequestTypeValue;
|
||||
// No default case so that we get a compiler warning if a new value was added to the enum.
|
||||
}
|
||||
}
|
||||
|
||||
+ (nullable FIRGetOOBConfirmationCodeRequest *)
|
||||
passwordResetRequestWithEmail:(NSString *)email
|
||||
actionCodeSettings:(nullable FIRActionCodeSettings *)actionCodeSettings
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration {
|
||||
return [[self alloc] initWithRequestType:FIRGetOOBConfirmationCodeRequestTypePasswordReset
|
||||
email:email
|
||||
newEmail:nil
|
||||
accessToken:nil
|
||||
actionCodeSettings:actionCodeSettings
|
||||
requestConfiguration:requestConfiguration];
|
||||
}
|
||||
|
||||
+ (nullable FIRGetOOBConfirmationCodeRequest *)
|
||||
verifyEmailRequestWithAccessToken:(NSString *)accessToken
|
||||
actionCodeSettings:(nullable FIRActionCodeSettings *)actionCodeSettings
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration {
|
||||
return [[self alloc] initWithRequestType:FIRGetOOBConfirmationCodeRequestTypeVerifyEmail
|
||||
email:nil
|
||||
newEmail:nil
|
||||
accessToken:accessToken
|
||||
actionCodeSettings:actionCodeSettings
|
||||
requestConfiguration:requestConfiguration];
|
||||
}
|
||||
|
||||
+ (nullable FIRGetOOBConfirmationCodeRequest *)
|
||||
signInWithEmailLinkRequest:(NSString *)email
|
||||
actionCodeSettings:(nullable FIRActionCodeSettings *)actionCodeSettings
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration {
|
||||
return [[self alloc] initWithRequestType:FIRGetOOBConfirmationCodeRequestTypeEmailLink
|
||||
email:email
|
||||
newEmail:nil
|
||||
accessToken:nil
|
||||
actionCodeSettings:actionCodeSettings
|
||||
requestConfiguration:requestConfiguration];
|
||||
}
|
||||
|
||||
+ (nullable FIRGetOOBConfirmationCodeRequest *)
|
||||
verifyBeforeUpdateEmailWithAccessToken:(NSString *)accessToken
|
||||
newEmail:(NSString *)newEmail
|
||||
actionCodeSettings:(nullable FIRActionCodeSettings *)actionCodeSettings
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration {
|
||||
return
|
||||
[[self alloc] initWithRequestType:FIRGetOOBConfirmationCodeRequestTypeVerifyBeforeUpdateEmail
|
||||
email:nil
|
||||
newEmail:newEmail
|
||||
accessToken:accessToken
|
||||
actionCodeSettings:actionCodeSettings
|
||||
requestConfiguration:requestConfiguration];
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithRequestType:(FIRGetOOBConfirmationCodeRequestType)requestType
|
||||
email:(nullable NSString *)email
|
||||
newEmail:(nullable NSString *)newEmail
|
||||
accessToken:(nullable NSString *)accessToken
|
||||
actionCodeSettings:(nullable FIRActionCodeSettings *)actionCodeSettings
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration {
|
||||
self = [super initWithEndpoint:kGetOobConfirmationCodeEndpoint
|
||||
requestConfiguration:requestConfiguration];
|
||||
if (self) {
|
||||
_requestType = requestType;
|
||||
_email = email;
|
||||
_updatedEmail = newEmail;
|
||||
_accessToken = accessToken;
|
||||
_continueURL = actionCodeSettings.URL.absoluteString;
|
||||
_iOSBundleID = actionCodeSettings.iOSBundleID;
|
||||
_androidPackageName = actionCodeSettings.androidPackageName;
|
||||
_androidMinimumVersion = actionCodeSettings.androidMinimumVersion;
|
||||
_androidInstallApp = actionCodeSettings.androidInstallIfNotAvailable;
|
||||
_handleCodeInApp = actionCodeSettings.handleCodeInApp;
|
||||
_dynamicLinkDomain = actionCodeSettings.dynamicLinkDomain;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (nullable id)unencodedHTTPRequestBodyWithError:(NSError *_Nullable *_Nullable)error {
|
||||
NSMutableDictionary *body =
|
||||
[@{kRequestTypeKey : [[self class] requestTypeStringValueForRequestType:_requestType]}
|
||||
mutableCopy];
|
||||
|
||||
// For password reset requests, we only need an email address in addition to the already required
|
||||
// fields.
|
||||
if (_requestType == FIRGetOOBConfirmationCodeRequestTypePasswordReset) {
|
||||
body[kEmailKey] = _email;
|
||||
}
|
||||
|
||||
// For verify email requests, we only need an STS Access Token in addition to the already required
|
||||
// fields.
|
||||
if (_requestType == FIRGetOOBConfirmationCodeRequestTypeVerifyEmail) {
|
||||
body[kIDTokenKey] = _accessToken;
|
||||
}
|
||||
|
||||
// For email sign-in link requests, we only need an email address in addition to the already
|
||||
// required fields.
|
||||
if (_requestType == FIRGetOOBConfirmationCodeRequestTypeEmailLink) {
|
||||
body[kEmailKey] = _email;
|
||||
}
|
||||
|
||||
// For email sign-in link requests, we only need an STS Access Token, a new email address in
|
||||
// addition to the already required fields.
|
||||
if (_requestType == FIRGetOOBConfirmationCodeRequestTypeVerifyBeforeUpdateEmail) {
|
||||
body[kNewEmailKey] = _updatedEmail;
|
||||
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;
|
||||
}
|
||||
|
||||
if (_dynamicLinkDomain) {
|
||||
body[kDynamicLinkDomainKey] = _dynamicLinkDomain;
|
||||
}
|
||||
if (self.tenantID) {
|
||||
body[kTenantIDKey] = self.tenantID;
|
||||
}
|
||||
|
||||
return body;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/FIRAuthRPCResponse.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @class FIRGetOOBConfirmationCodeResponse
|
||||
@brief Represents the response from the getOobConfirmationCode endpoint.
|
||||
*/
|
||||
@interface FIRGetOOBConfirmationCodeResponse : NSObject <FIRAuthRPCResponse>
|
||||
|
||||
/** @property OOBCode
|
||||
@brief The OOB code returned by the server in some cases.
|
||||
*/
|
||||
@property(nonatomic, copy, readonly, nullable) NSString *OOBCode;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/RPC/FIRGetOOBConfirmationCodeResponse.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @var kOOBCodeKey
|
||||
@brief The name of the field in the response JSON for the OOB code.
|
||||
*/
|
||||
static NSString *const kOOBCodeKey = @"oobCode";
|
||||
|
||||
@implementation FIRGetOOBConfirmationCodeResponse
|
||||
|
||||
- (BOOL)setWithDictionary:(NSDictionary *)dictionary error:(NSError *_Nullable *_Nullable)error {
|
||||
_OOBCode = [dictionary[kOOBCodeKey] copy];
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/FIRAuthRPCRequest.h"
|
||||
#import "FirebaseAuth/Sources/Backend/FIRIdentityToolkitRequest.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FIRGetProjectConfigRequest : FIRIdentityToolkitRequest <FIRAuthRPCRequest>
|
||||
|
||||
/** @fn initWithEndpoint:requestConfiguration:
|
||||
@brief Please use initWithRequestConfiguration:
|
||||
*/
|
||||
- (nullable instancetype)initWithEndpoint:(NSString *)endpoint
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
|
||||
NS_UNAVAILABLE;
|
||||
|
||||
/** @fn initWithTemporaryProof:phoneNumberAPIKey
|
||||
@brief Designated initializer.
|
||||
@param requestConfiguration An object containing configurations to be added to the request.
|
||||
*/
|
||||
- (nullable instancetype)initWithRequestConfiguration:
|
||||
(FIRAuthRequestConfiguration *)requestConfiguration NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/RPC/FIRGetProjectConfigRequest.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @var kGetProjectConfigEndPoint
|
||||
@brief The "getProjectConfig" endpoint.
|
||||
*/
|
||||
static NSString *const kGetProjectConfigEndPoint = @"getProjectConfig";
|
||||
|
||||
@implementation FIRGetProjectConfigRequest
|
||||
|
||||
- (nullable instancetype)initWithRequestConfiguration:
|
||||
(FIRAuthRequestConfiguration *)requestConfiguration {
|
||||
return [super initWithEndpoint:kGetProjectConfigEndPoint
|
||||
requestConfiguration:requestConfiguration];
|
||||
}
|
||||
|
||||
- (BOOL)containsPostBody {
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/FIRAuthRPCResponse.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @class FIRGetProjectConfigResponse
|
||||
@brief Represents the response from the getProjectConfig endpoint.
|
||||
*/
|
||||
@interface FIRGetProjectConfigResponse : NSObject <FIRAuthRPCResponse>
|
||||
|
||||
/** @property projectID
|
||||
@brief The unique ID pertaining to the current project.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSString *projectID;
|
||||
|
||||
/** @property authorizedDomains
|
||||
@brief A list of domains allowlisted for the current project.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSArray *authorizedDomains;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/RPC/FIRGetProjectConfigResponse.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation FIRGetProjectConfigResponse
|
||||
|
||||
- (BOOL)setWithDictionary:(NSDictionary *)dictionary error:(NSError *_Nullable *_Nullable)error {
|
||||
_projectID = [dictionary[@"projectId"] copy];
|
||||
id authorizedDomains = dictionary[@"authorizedDomains"];
|
||||
if ([authorizedDomains isKindOfClass:[NSString class]]) {
|
||||
NSData *data = [authorizedDomains dataUsingEncoding:NSUTF8StringEncoding];
|
||||
authorizedDomains = [NSJSONSerialization JSONObjectWithData:data
|
||||
options:NSJSONReadingMutableLeaves
|
||||
error:nil];
|
||||
}
|
||||
if ([authorizedDomains isKindOfClass:[NSArray class]]) {
|
||||
_authorizedDomains = [[NSArray alloc] initWithArray:authorizedDomains copyItems:YES];
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/FIRAuthRPCRequest.h"
|
||||
#import "FirebaseAuth/Sources/Backend/FIRIdentityToolkitRequest.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FIRResetPasswordRequest : FIRIdentityToolkitRequest <FIRAuthRPCRequest>
|
||||
|
||||
/** @property oobCode
|
||||
@brief The oobCode sent in the request.
|
||||
*/
|
||||
@property(nonatomic, copy, readonly) NSString *oobCode;
|
||||
|
||||
/** @property updatedPassword
|
||||
@brief The new password sent in the request.
|
||||
*/
|
||||
@property(nonatomic, copy, readonly) NSString *updatedPassword;
|
||||
|
||||
/** @fn initWithEndpoint:requestConfiguration:
|
||||
@brief Please use initWithOobCode:newPassword:requestConfiguration: instead.
|
||||
*/
|
||||
- (nullable instancetype)initWithEndpoint:(NSString *)endpoint
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
|
||||
NS_UNAVAILABLE;
|
||||
|
||||
/** @fn initWithOobCode:newPassword:requestConfiguration:
|
||||
@brief Designated initializer.
|
||||
@param oobCode The OOB Code.
|
||||
@param newPassword The new password.
|
||||
@param requestConfiguration An object containing configurations to be added to the request.
|
||||
*/
|
||||
- (nullable instancetype)initWithOobCode:(NSString *)oobCode
|
||||
newPassword:(nullable NSString *)newPassword
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/RPC/FIRResetPasswordRequest.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @var kResetPasswordEndpoint
|
||||
@brief The "resetPassword" endpoint.
|
||||
*/
|
||||
static NSString *const kResetPasswordEndpoint = @"resetPassword";
|
||||
|
||||
/** @var kOOBCodeKey
|
||||
@brief The "resetPassword" key.
|
||||
*/
|
||||
static NSString *const kOOBCodeKey = @"oobCode";
|
||||
|
||||
/** @var kCurrentPasswordKey
|
||||
@brief The "newPassword" key.
|
||||
*/
|
||||
static NSString *const kCurrentPasswordKey = @"newPassword";
|
||||
|
||||
/** @var kTenantIDKey
|
||||
@brief The key for the tenant id value in the request.
|
||||
*/
|
||||
static NSString *const kTenantIDKey = @"tenantId";
|
||||
|
||||
@implementation FIRResetPasswordRequest
|
||||
|
||||
- (nullable instancetype)initWithOobCode:(NSString *)oobCode
|
||||
newPassword:(nullable NSString *)newPassword
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration {
|
||||
self = [super initWithEndpoint:kResetPasswordEndpoint requestConfiguration:requestConfiguration];
|
||||
if (self) {
|
||||
_oobCode = oobCode;
|
||||
_updatedPassword = newPassword;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (nullable id)unencodedHTTPRequestBodyWithError:(NSError *_Nullable *_Nullable)error {
|
||||
NSMutableDictionary *postBody = [NSMutableDictionary dictionary];
|
||||
postBody[kOOBCodeKey] = _oobCode;
|
||||
if (_updatedPassword) {
|
||||
postBody[kCurrentPasswordKey] = _updatedPassword;
|
||||
}
|
||||
if (self.tenantID) {
|
||||
postBody[kTenantIDKey] = self.tenantID;
|
||||
}
|
||||
return [postBody copy];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/FIRAuthRPCResponse.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @class FIRAuthResetPasswordResponse
|
||||
@brief Represents the response from the resetPassword endpoint.
|
||||
@remarks Possible error codes:
|
||||
- FIRAuthErrorCodeWeakPassword
|
||||
- FIRAuthErrorCodeUserDisabled
|
||||
- FIRAuthErrorCodeOperationNotAllowed
|
||||
- FIRAuthErrorCodeExpiredActionCode
|
||||
- FIRAuthErrorCodeInvalidActionCode
|
||||
@see https://developers.google.com/identity/toolkit/web/reference/relyingparty/resetPassword
|
||||
*/
|
||||
@interface FIRResetPasswordResponse : NSObject <FIRAuthRPCResponse>
|
||||
|
||||
/** @property email
|
||||
@brief The email address corresponding to the reset password request.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly) NSString *email;
|
||||
|
||||
/** @property verifiedEmail
|
||||
@brief The verified email returned from the backend.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly) NSString *verifiedEmail;
|
||||
|
||||
/** @property requestType
|
||||
@brief The tpye of request as returned by the backend.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly) NSString *requestType;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/RPC/FIRResetPasswordResponse.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation FIRResetPasswordResponse
|
||||
|
||||
- (BOOL)setWithDictionary:(NSDictionary *)dictionary error:(NSError *_Nullable *_Nullable)error {
|
||||
_email = [dictionary[@"email"] copy];
|
||||
_requestType = [dictionary[@"requestType"] copy];
|
||||
_verifiedEmail = [dictionary[@"newEmail"] copy];
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/FIRAuthRPCRequest.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @enum FIRSecureTokenRequestGrantType
|
||||
@brief Represents the possible grant types for a token request.
|
||||
*/
|
||||
typedef NS_ENUM(NSUInteger, FIRSecureTokenRequestGrantType) {
|
||||
/** @var FIRSecureTokenRequestGrantTypeAuthorizationCode
|
||||
@brief Indicates an authorization code request.
|
||||
@remarks Exchanges a Gitkit "ID Token" for an STS Access Token and Refresh Token.
|
||||
*/
|
||||
FIRSecureTokenRequestGrantTypeAuthorizationCode,
|
||||
|
||||
/** @var FIRSecureTokenRequestGrantTypeRefreshToken
|
||||
@brief Indicates an refresh token request.
|
||||
@remarks Uses an existing Refresh Token to create a new Access Token.
|
||||
*/
|
||||
FIRSecureTokenRequestGrantTypeRefreshToken,
|
||||
};
|
||||
|
||||
/** @class FIRSecureTokenRequest
|
||||
@brief Represents the parameters for the token endpoint.
|
||||
*/
|
||||
@interface FIRSecureTokenRequest : NSObject <FIRAuthRPCRequest>
|
||||
|
||||
/** @property grantType
|
||||
@brief The type of grant requested.
|
||||
@see FIRSecureTokenRequestGrantType
|
||||
*/
|
||||
@property(nonatomic, assign, readonly) FIRSecureTokenRequestGrantType grantType;
|
||||
|
||||
/** @property scope
|
||||
@brief The scopes requested (a comma-delimited list of scope strings.)
|
||||
*/
|
||||
@property(nonatomic, copy, readonly, nullable) NSString *scope;
|
||||
|
||||
/** @property refreshToken
|
||||
@brief The client's refresh token.
|
||||
*/
|
||||
@property(nonatomic, copy, readonly, nullable) NSString *refreshToken;
|
||||
|
||||
/** @property code
|
||||
@brief The client's authorization code (legacy Gitkit "ID Token").
|
||||
*/
|
||||
@property(nonatomic, copy, readonly, nullable) NSString *code;
|
||||
|
||||
/** @property APIKey
|
||||
@brief The client's API Key.
|
||||
*/
|
||||
@property(nonatomic, copy, readonly) NSString *APIKey;
|
||||
|
||||
/** @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 requestConfiguration An object containing configurations to be added to the request.
|
||||
@return An authorization request.
|
||||
*/
|
||||
+ (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 requestConfiguration An object containing configurations to be added to the request.
|
||||
@return A refresh request.
|
||||
*/
|
||||
+ (FIRSecureTokenRequest *)refreshRequestWithRefreshToken:(NSString *)refreshToken
|
||||
requestConfiguration:
|
||||
(FIRAuthRequestConfiguration *)requestConfiguration;
|
||||
|
||||
/** @fn init
|
||||
@brief Please use initWithGrantType:scope:refreshToken:code:
|
||||
*/
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
/** @fn initWithGrantType:scope:refreshToken:code:APIKey:
|
||||
@brief Designated initializer.
|
||||
@param grantType The type of request.
|
||||
@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 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
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
|
||||
NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/RPC/FIRSecureTokenRequest.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/Backend/FIRAuthRequestConfiguration.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @var kFIRSecureTokenServiceGetTokenURLFormat
|
||||
@brief The format of the secure token service URLs. Requires string format substitution with
|
||||
the client's API Key.
|
||||
*/
|
||||
static NSString *const kFIRSecureTokenServiceGetTokenURLFormat = @"https://%@/v1/token?key=%@";
|
||||
|
||||
/** @var kFIREmulatorURLFormat
|
||||
@brief The format of the emulated secure token service URLs. Requires string format substitution
|
||||
with the emulator host, the gAPIHost, and the client's API Key.
|
||||
*/
|
||||
static NSString *const kFIREmulatorURLFormat = @"http://%@/%@/v1/token?key=%@";
|
||||
|
||||
/** @var kFIRSecureTokenServiceGrantTypeRefreshToken
|
||||
@brief The string value of the @c FIRSecureTokenRequestGrantTypeRefreshToken request type.
|
||||
*/
|
||||
static NSString *const kFIRSecureTokenServiceGrantTypeRefreshToken = @"refresh_token";
|
||||
|
||||
/** @var kFIRSecureTokenServiceGrantTypeAuthorizationCode
|
||||
@brief The string value of the @c FIRSecureTokenRequestGrantTypeAuthorizationCode request type.
|
||||
*/
|
||||
static NSString *const kFIRSecureTokenServiceGrantTypeAuthorizationCode = @"authorization_code";
|
||||
|
||||
/** @var kGrantTypeKey
|
||||
@brief The key for the "grantType" parameter in the request.
|
||||
*/
|
||||
static NSString *const kGrantTypeKey = @"grantType";
|
||||
|
||||
/** @var kScopeKey
|
||||
@brief The key for the "scope" parameter in the request.
|
||||
*/
|
||||
static NSString *const kScopeKey = @"scope";
|
||||
|
||||
/** @var kRefreshTokenKey
|
||||
@brief The key for the "refreshToken" parameter in the request.
|
||||
*/
|
||||
static NSString *const kRefreshTokenKey = @"refreshToken";
|
||||
|
||||
/** @var kCodeKey
|
||||
@brief The key for the "code" parameter in the request.
|
||||
*/
|
||||
static NSString *const kCodeKey = @"code";
|
||||
|
||||
/** @var gAPIHost
|
||||
@brief Host for server API calls.
|
||||
*/
|
||||
static NSString *gAPIHost = @"securetoken.googleapis.com";
|
||||
|
||||
@implementation FIRSecureTokenRequest {
|
||||
/** @var _requestConfiguration
|
||||
@brief Contains configuration relevant to the request.
|
||||
*/
|
||||
FIRAuthRequestConfiguration *_requestConfiguration;
|
||||
}
|
||||
|
||||
+ (FIRSecureTokenRequest *)authCodeRequestWithCode:(NSString *)code
|
||||
requestConfiguration:
|
||||
(FIRAuthRequestConfiguration *)requestConfiguration {
|
||||
return [[self alloc] initWithGrantType:FIRSecureTokenRequestGrantTypeAuthorizationCode
|
||||
scope:nil
|
||||
refreshToken:nil
|
||||
code:code
|
||||
requestConfiguration:requestConfiguration];
|
||||
}
|
||||
|
||||
+ (FIRSecureTokenRequest *)refreshRequestWithRefreshToken:(NSString *)refreshToken
|
||||
requestConfiguration:
|
||||
(FIRAuthRequestConfiguration *)requestConfiguration {
|
||||
return [[self alloc] initWithGrantType:FIRSecureTokenRequestGrantTypeRefreshToken
|
||||
scope:nil
|
||||
refreshToken:refreshToken
|
||||
code:nil
|
||||
requestConfiguration:requestConfiguration];
|
||||
}
|
||||
|
||||
/** @fn grantTypeStringWithGrantType:
|
||||
@brief Converts a @c FIRSecureTokenRequestGrantType to it's @c NSString equivilent.
|
||||
*/
|
||||
+ (NSString *)grantTypeStringWithGrantType:(FIRSecureTokenRequestGrantType)grantType {
|
||||
switch (grantType) {
|
||||
case FIRSecureTokenRequestGrantTypeAuthorizationCode:
|
||||
return kFIRSecureTokenServiceGrantTypeAuthorizationCode;
|
||||
case FIRSecureTokenRequestGrantTypeRefreshToken:
|
||||
return kFIRSecureTokenServiceGrantTypeRefreshToken;
|
||||
// No Default case so we will notice if new grant types are added to the enum.
|
||||
}
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithGrantType:(FIRSecureTokenRequestGrantType)grantType
|
||||
scope:(nullable NSString *)scope
|
||||
refreshToken:(nullable NSString *)refreshToken
|
||||
code:(nullable NSString *)code
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_grantType = grantType;
|
||||
_scope = [scope copy];
|
||||
_refreshToken = [refreshToken copy];
|
||||
_code = [code copy];
|
||||
_APIKey = [requestConfiguration.APIKey copy];
|
||||
_requestConfiguration = requestConfiguration;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (FIRAuthRequestConfiguration *)requestConfiguration {
|
||||
return _requestConfiguration;
|
||||
}
|
||||
|
||||
- (NSURL *)requestURL {
|
||||
NSString *URLString;
|
||||
|
||||
NSString *emulatorHostAndPort = _requestConfiguration.emulatorHostAndPort;
|
||||
if (emulatorHostAndPort) {
|
||||
URLString =
|
||||
[NSString stringWithFormat:kFIREmulatorURLFormat, emulatorHostAndPort, gAPIHost, _APIKey];
|
||||
} else {
|
||||
URLString =
|
||||
[NSString stringWithFormat:kFIRSecureTokenServiceGetTokenURLFormat, gAPIHost, _APIKey];
|
||||
}
|
||||
NSURL *URL = [NSURL URLWithString:URLString];
|
||||
return URL;
|
||||
}
|
||||
|
||||
- (BOOL)containsPostBody {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (nullable id)unencodedHTTPRequestBodyWithError:(NSError *_Nullable *_Nullable)error {
|
||||
NSMutableDictionary *postBody =
|
||||
[@{kGrantTypeKey : [[self class] grantTypeStringWithGrantType:_grantType]} mutableCopy];
|
||||
if (_scope) {
|
||||
postBody[kScopeKey] = _scope;
|
||||
}
|
||||
if (_refreshToken) {
|
||||
postBody[kRefreshTokenKey] = _refreshToken;
|
||||
}
|
||||
if (_code) {
|
||||
postBody[kCodeKey] = _code;
|
||||
}
|
||||
return [postBody copy];
|
||||
}
|
||||
|
||||
#pragma mark - Internal API for development
|
||||
|
||||
+ (NSString *)host {
|
||||
return gAPIHost;
|
||||
}
|
||||
|
||||
+ (void)setHost:(NSString *)host {
|
||||
gAPIHost = host;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/FIRAuthRPCResponse.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @class FIRSecureTokenResponse
|
||||
@brief Represents the response from the token endpoint.
|
||||
*/
|
||||
@interface FIRSecureTokenResponse : NSObject <FIRAuthRPCResponse>
|
||||
|
||||
/** @property approximateExpirationDate
|
||||
@brief The approximate expiration date of the access token.
|
||||
*/
|
||||
@property(nonatomic, copy, readonly, nullable) NSDate *approximateExpirationDate;
|
||||
|
||||
/** @property refreshToken
|
||||
@brief The refresh token. (Possibly an updated one for refresh requests.)
|
||||
*/
|
||||
@property(nonatomic, copy, readonly, nullable) NSString *refreshToken;
|
||||
|
||||
/** @property accessToken
|
||||
@brief The new access token.
|
||||
*/
|
||||
@property(nonatomic, copy, readonly, nullable) NSString *accessToken;
|
||||
|
||||
/** @property IDToken
|
||||
@brief The new ID Token.
|
||||
*/
|
||||
@property(nonatomic, copy, readonly, nullable) NSString *IDToken;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/RPC/FIRSecureTokenResponse.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/Utilities/FIRAuthErrorUtils.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @var kExpiresInKey
|
||||
@brief The key for the number of seconds till the access token expires.
|
||||
*/
|
||||
static NSString *const kExpiresInKey = @"expires_in";
|
||||
|
||||
/** @var kRefreshTokenKey
|
||||
@brief The key for the refresh token.
|
||||
*/
|
||||
static NSString *const kRefreshTokenKey = @"refresh_token";
|
||||
|
||||
/** @var kAccessTokenKey
|
||||
@brief The key for the access token.
|
||||
*/
|
||||
static NSString *const kAccessTokenKey = @"access_token";
|
||||
|
||||
/** @var kIDTokenKey
|
||||
@brief The key for the "id_token" value in the response.
|
||||
*/
|
||||
static NSString *const kIDTokenKey = @"id_token";
|
||||
|
||||
@implementation FIRSecureTokenResponse
|
||||
|
||||
- (nullable NSString *)expectedKind {
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL)setWithDictionary:(NSDictionary *)dictionary error:(NSError *_Nullable *_Nullable)error {
|
||||
_refreshToken = dictionary[kRefreshTokenKey];
|
||||
_accessToken = dictionary[kAccessTokenKey];
|
||||
_IDToken = dictionary[kIDTokenKey];
|
||||
if (!_accessToken.length) {
|
||||
if (error) {
|
||||
*error = [FIRAuthErrorUtils unexpectedResponseWithDeserializedResponse:dictionary];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
id expiresIn = dictionary[kExpiresInKey];
|
||||
if (![expiresIn isKindOfClass:[NSString class]]) {
|
||||
if (error) {
|
||||
*error = [FIRAuthErrorUtils unexpectedResponseWithDeserializedResponse:dictionary];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
_approximateExpirationDate = [NSDate dateWithTimeIntervalSinceNow:[expiresIn doubleValue]];
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/FIRAuthRPCRequest.h"
|
||||
#import "FirebaseAuth/Sources/Backend/FIRIdentityToolkitRequest.h"
|
||||
|
||||
@class FIRAuthAppCredential;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FIRSendVerificationCodeRequest : FIRIdentityToolkitRequest <FIRAuthRPCRequest>
|
||||
|
||||
/** @property phoneNumber
|
||||
@brief The phone number to which the verification code should be sent.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly) NSString *phoneNumber;
|
||||
|
||||
/** @property appCredential
|
||||
@brief The credential to prove the identity of the app in order to send the verification code.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) FIRAuthAppCredential *appCredential;
|
||||
|
||||
/** @property reCAPTCHAToken
|
||||
@brief The reCAPTCHA token to prove the identity of the app in order to send the verification
|
||||
code.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSString *reCAPTCHAToken;
|
||||
|
||||
/** @fn initWithEndpoint:requestConfiguration:
|
||||
@brief Please use initWithPhoneNumber:appCredentials:requestConfiguration: instead.
|
||||
*/
|
||||
- (nullable instancetype)initWithEndpoint:(NSString *)endpoint
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
|
||||
NS_UNAVAILABLE;
|
||||
|
||||
/** @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 reCAPTCHAToken The reCAPTCHA token that proves the identity of the app.
|
||||
@param requestConfiguration An object containing configurations to be added to the request.
|
||||
*/
|
||||
- (nullable instancetype)initWithPhoneNumber:(NSString *)phoneNumber
|
||||
appCredential:(nullable FIRAuthAppCredential *)appCredential
|
||||
reCAPTCHAToken:(nullable NSString *)reCAPTCHAToken
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
|
||||
NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/RPC/FIRSendVerificationCodeRequest.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/SystemService/FIRAuthAppCredential.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @var kSendVerificationCodeEndPoint
|
||||
@brief The "sendVerificationCodeEnd" endpoint.
|
||||
*/
|
||||
static NSString *const kSendVerificationCodeEndPoint = @"sendVerificationCode";
|
||||
|
||||
/** @var kPhoneNumberKey
|
||||
@brief The key for the Phone Number parameter in the request.
|
||||
*/
|
||||
static NSString *const kPhoneNumberKey = @"phoneNumber";
|
||||
|
||||
/** @var kReceiptKey
|
||||
@brief The key for the receipt parameter in the request.
|
||||
*/
|
||||
static NSString *const kReceiptKey = @"iosReceipt";
|
||||
|
||||
/** @var kSecretKey
|
||||
@brief The key for the Secret parameter in the request.
|
||||
*/
|
||||
static NSString *const kSecretKey = @"iosSecret";
|
||||
|
||||
/** @var kreCAPTCHATokenKey
|
||||
@brief The key for the reCAPTCHAToken parameter in the request.
|
||||
*/
|
||||
static NSString *const kreCAPTCHATokenKey = @"recaptchaToken";
|
||||
|
||||
/** @var kTenantIDKey
|
||||
@brief The key for the tenant id value in the request.
|
||||
*/
|
||||
static NSString *const kTenantIDKey = @"tenantId";
|
||||
|
||||
@implementation FIRSendVerificationCodeRequest {
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithPhoneNumber:(NSString *)phoneNumber
|
||||
appCredential:(nullable FIRAuthAppCredential *)appCredential
|
||||
reCAPTCHAToken:(nullable NSString *)reCAPTCHAToken
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration {
|
||||
self = [super initWithEndpoint:kSendVerificationCodeEndPoint
|
||||
requestConfiguration:requestConfiguration];
|
||||
if (self) {
|
||||
_phoneNumber = [phoneNumber copy];
|
||||
_appCredential = appCredential;
|
||||
_reCAPTCHAToken = [reCAPTCHAToken copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (nullable id)unencodedHTTPRequestBodyWithError:(NSError *_Nullable *_Nullable)error {
|
||||
NSMutableDictionary *postBody = [NSMutableDictionary dictionary];
|
||||
if (_phoneNumber) {
|
||||
postBody[kPhoneNumberKey] = _phoneNumber;
|
||||
}
|
||||
if (_appCredential.receipt) {
|
||||
postBody[kReceiptKey] = _appCredential.receipt;
|
||||
}
|
||||
if (_appCredential.secret) {
|
||||
postBody[kSecretKey] = _appCredential.secret;
|
||||
}
|
||||
if (_reCAPTCHAToken) {
|
||||
postBody[kreCAPTCHATokenKey] = _reCAPTCHAToken;
|
||||
}
|
||||
if (self.tenantID) {
|
||||
postBody[kTenantIDKey] = self.tenantID;
|
||||
}
|
||||
return [postBody copy];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/FIRAuthRPCResponse.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FIRSendVerificationCodeResponse : NSObject <FIRAuthRPCResponse>
|
||||
|
||||
/** @property verificationID
|
||||
@brief Encrypted session information returned by the backend.
|
||||
*/
|
||||
@property(nonatomic, readonly) NSString *verificationID;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/RPC/FIRSendVerificationCodeResponse.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation FIRSendVerificationCodeResponse
|
||||
|
||||
// TODO: remove when resolving b/37169084 .
|
||||
- (nullable NSString *)expectedKind {
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL)setWithDictionary:(NSDictionary *)dictionary error:(NSError *_Nullable *_Nullable)error {
|
||||
_verificationID = [dictionary[@"sessionInfo"] copy];
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/FIRAuthRPCRequest.h"
|
||||
#import "FirebaseAuth/Sources/Backend/FIRIdentityToolkitRequest.h"
|
||||
|
||||
@class FIRGetAccountInfoResponse;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @var FIRSetAccountInfoUserAttributeEmail
|
||||
@brief Constant for email attribute used in "deleteAttributes".
|
||||
*/
|
||||
extern NSString *const FIRSetAccountInfoUserAttributeEmail;
|
||||
|
||||
/** @var FIRSetAccountInfoUserAttributeDisplayName
|
||||
@brief Constant for displayName attribute used in "deleteAttributes".
|
||||
*/
|
||||
extern NSString *const FIRSetAccountInfoUserAttributeDisplayName;
|
||||
|
||||
/** @var FIRSetAccountInfoUserAttributeProvider
|
||||
@brief Constant for provider attribute used in "deleteAttributes".
|
||||
*/
|
||||
extern NSString *const FIRSetAccountInfoUserAttributeProvider;
|
||||
|
||||
/** @var FIRSetAccountInfoUserAttributePhotoURL
|
||||
@brief Constant for photoURL attribute used in "deleteAttributes".
|
||||
*/
|
||||
extern NSString *const FIRSetAccountInfoUserAttributePhotoURL;
|
||||
|
||||
/** @var FIRSetAccountInfoUserAttributePassword
|
||||
@brief Constant for password attribute used in "deleteAttributes".
|
||||
*/
|
||||
extern NSString *const FIRSetAccountInfoUserAttributePassword;
|
||||
|
||||
/** @class FIRSetAccountInfoRequest
|
||||
@brief Represents the parameters for the setAccountInfo endpoint.
|
||||
@see https://developers.google.com/identity/toolkit/web/reference/relyingparty/setAccountInfo
|
||||
*/
|
||||
@interface FIRSetAccountInfoRequest : FIRIdentityToolkitRequest <FIRAuthRPCRequest>
|
||||
|
||||
/** @property accessToken
|
||||
@brief The STS Access Token of the authenticated user.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSString *accessToken;
|
||||
|
||||
/** @property displayName
|
||||
@brief The name of the user.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSString *displayName;
|
||||
|
||||
/** @property localID
|
||||
@brief The local ID of the user.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSString *localID;
|
||||
|
||||
/** @property email
|
||||
@brief The email of the user.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSString *email;
|
||||
|
||||
/** @property photoURL
|
||||
@brief The photoURL of the user.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSURL *photoURL;
|
||||
|
||||
/** @property password
|
||||
@brief The new password of the user.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSString *password;
|
||||
|
||||
/** @property providers
|
||||
@brief The associated identity providers of the user.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSArray<NSString *> *providers;
|
||||
|
||||
/** @property OOBCode
|
||||
@brief The out-of-band code of the change email request.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSString *OOBCode;
|
||||
|
||||
/** @property emailVerified
|
||||
@brief Whether to mark the email as verified or not.
|
||||
*/
|
||||
@property(nonatomic, assign) BOOL emailVerified;
|
||||
|
||||
/** @property upgradeToFederatedLogin
|
||||
@brief Whether to mark the user to upgrade to federated login.
|
||||
*/
|
||||
@property(nonatomic, assign) BOOL upgradeToFederatedLogin;
|
||||
|
||||
/** @property captchaChallenge
|
||||
@brief The captcha challenge.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSString *captchaChallenge;
|
||||
|
||||
/** @property captchaResponse
|
||||
@brief Response to the captcha.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSString *captchaResponse;
|
||||
|
||||
/** @property deleteAttributes
|
||||
@brief The list of user attributes to delete.
|
||||
@remarks Every element of the list must be one of the predefined constant starts with
|
||||
"FIRSetAccountInfoUserAttribute".
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSArray<NSString *> *deleteAttributes;
|
||||
|
||||
/** @property deleteProviders
|
||||
@brief The list of identity providers to delete.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSArray<NSString *> *deleteProviders;
|
||||
|
||||
/** @property returnSecureToken
|
||||
@brief Whether the response should return access token and refresh token directly.
|
||||
@remarks The default value is @c YES .
|
||||
*/
|
||||
@property(nonatomic, assign) BOOL returnSecureToken;
|
||||
|
||||
/** @fn initWithEndpoint:requestConfiguration:
|
||||
@brief Please use initWithAPIKey:email:password:displayName:requestConfiguration instead.
|
||||
*/
|
||||
- (nullable instancetype)initWithEndpoint:(NSString *)endpoint
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
|
||||
NS_UNAVAILABLE;
|
||||
|
||||
/** @fn initWithRequestConfiguration:
|
||||
@brief Designated initializer.
|
||||
@param requestConfiguration An object containing configurations to be added to the request.
|
||||
*/
|
||||
- (nullable instancetype)initWithRequestConfiguration:
|
||||
(FIRAuthRequestConfiguration *)requestConfiguration NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+187
@@ -0,0 +1,187 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/RPC/FIRSetAccountInfoRequest.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/Auth/FIRAuth_Internal.h"
|
||||
#import "FirebaseAuth/Sources/Backend/RPC/FIRGetAccountInfoResponse.h"
|
||||
#import "FirebaseAuth/Sources/Utilities/FIRAuthErrorUtils.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
NSString *const FIRSetAccountInfoUserAttributeEmail = @"EMAIL";
|
||||
|
||||
NSString *const FIRSetAccountInfoUserAttributeDisplayName = @"DISPLAY_NAME";
|
||||
|
||||
NSString *const FIRSetAccountInfoUserAttributeProvider = @"PROVIDER";
|
||||
|
||||
NSString *const FIRSetAccountInfoUserAttributePhotoURL = @"PHOTO_URL";
|
||||
|
||||
NSString *const FIRSetAccountInfoUserAttributePassword = @"PASSWORD";
|
||||
|
||||
/** @var kCreateAuthURIEndpoint
|
||||
@brief The "setAccountInfo" endpoint.
|
||||
*/
|
||||
static NSString *const kSetAccountInfoEndpoint = @"setAccountInfo";
|
||||
|
||||
/** @var kIDTokenKey
|
||||
@brief The key for the "idToken" value in the request. This is actually the STS Access Token,
|
||||
despite it's confusing (backwards compatiable) parameter name.
|
||||
*/
|
||||
static NSString *const kIDTokenKey = @"idToken";
|
||||
|
||||
/** @var kDisplayNameKey
|
||||
@brief The key for the "displayName" value in the request.
|
||||
*/
|
||||
static NSString *const kDisplayNameKey = @"displayName";
|
||||
|
||||
/** @var kLocalIDKey
|
||||
@brief The key for the "localID" value in the request.
|
||||
*/
|
||||
static NSString *const kLocalIDKey = @"localId";
|
||||
|
||||
/** @var kEmailKey
|
||||
@brief The key for the "email" value in the request.
|
||||
*/
|
||||
static NSString *const kEmailKey = @"email";
|
||||
|
||||
/** @var kPasswordKey
|
||||
@brief The key for the "password" value in the request.
|
||||
*/
|
||||
static NSString *const kPasswordKey = @"password";
|
||||
|
||||
/** @var kPhotoURLKey
|
||||
@brief The key for the "photoURL" value in the request.
|
||||
*/
|
||||
static NSString *const kPhotoURLKey = @"photoUrl";
|
||||
|
||||
/** @var kProvidersKey
|
||||
@brief The key for the "providers" value in the request.
|
||||
*/
|
||||
static NSString *const kProvidersKey = @"provider";
|
||||
|
||||
/** @var kOOBCodeKey
|
||||
@brief The key for the "OOBCode" value in the request.
|
||||
*/
|
||||
static NSString *const kOOBCodeKey = @"oobCode";
|
||||
|
||||
/** @var kEmailVerifiedKey
|
||||
@brief The key for the "emailVerified" value in the request.
|
||||
*/
|
||||
static NSString *const kEmailVerifiedKey = @"emailVerified";
|
||||
|
||||
/** @var kUpgradeToFederatedLoginKey
|
||||
@brief The key for the "upgradeToFederatedLogin" value in the request.
|
||||
*/
|
||||
static NSString *const kUpgradeToFederatedLoginKey = @"upgradeToFederatedLogin";
|
||||
|
||||
/** @var kCaptchaChallengeKey
|
||||
@brief The key for the "captchaChallenge" value in the request.
|
||||
*/
|
||||
static NSString *const kCaptchaChallengeKey = @"captchaChallenge";
|
||||
|
||||
/** @var kCaptchaResponseKey
|
||||
@brief The key for the "captchaResponse" value in the request.
|
||||
*/
|
||||
static NSString *const kCaptchaResponseKey = @"captchaResponse";
|
||||
|
||||
/** @var kDeleteAttributesKey
|
||||
@brief The key for the "deleteAttribute" value in the request.
|
||||
*/
|
||||
static NSString *const kDeleteAttributesKey = @"deleteAttribute";
|
||||
|
||||
/** @var kDeleteProvidersKey
|
||||
@brief The key for the "deleteProvider" value in the request.
|
||||
*/
|
||||
static NSString *const kDeleteProvidersKey = @"deleteProvider";
|
||||
|
||||
/** @var kReturnSecureTokenKey
|
||||
@brief The key for the "returnSecureToken" value in the request.
|
||||
*/
|
||||
static NSString *const kReturnSecureTokenKey = @"returnSecureToken";
|
||||
|
||||
/** @var kTenantIDKey
|
||||
@brief The key for the tenant id value in the request.
|
||||
*/
|
||||
static NSString *const kTenantIDKey = @"tenantId";
|
||||
|
||||
@implementation FIRSetAccountInfoRequest
|
||||
|
||||
- (nullable instancetype)initWithRequestConfiguration:
|
||||
(FIRAuthRequestConfiguration *)requestConfiguration {
|
||||
self = [super initWithEndpoint:kSetAccountInfoEndpoint requestConfiguration:requestConfiguration];
|
||||
if (self) {
|
||||
_returnSecureToken = YES;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (nullable id)unencodedHTTPRequestBodyWithError:(NSError *_Nullable *_Nullable)error {
|
||||
NSMutableDictionary *postBody = [NSMutableDictionary dictionary];
|
||||
if (_accessToken) {
|
||||
postBody[kIDTokenKey] = _accessToken;
|
||||
}
|
||||
if (_displayName) {
|
||||
postBody[kDisplayNameKey] = _displayName;
|
||||
}
|
||||
if (_localID) {
|
||||
postBody[kLocalIDKey] = _localID;
|
||||
}
|
||||
if (_email) {
|
||||
postBody[kEmailKey] = _email;
|
||||
}
|
||||
if (_password) {
|
||||
postBody[kPasswordKey] = _password;
|
||||
}
|
||||
if (_photoURL) {
|
||||
postBody[kPhotoURLKey] = _photoURL.absoluteString;
|
||||
}
|
||||
if (_providers) {
|
||||
postBody[kProvidersKey] = _providers;
|
||||
}
|
||||
if (_OOBCode) {
|
||||
postBody[kOOBCodeKey] = _OOBCode;
|
||||
}
|
||||
if (_emailVerified) {
|
||||
postBody[kEmailVerifiedKey] = @YES;
|
||||
}
|
||||
if (_upgradeToFederatedLogin) {
|
||||
postBody[kUpgradeToFederatedLoginKey] = @YES;
|
||||
}
|
||||
if (_captchaChallenge) {
|
||||
postBody[kCaptchaChallengeKey] = _captchaChallenge;
|
||||
}
|
||||
if (_captchaResponse) {
|
||||
postBody[kCaptchaResponseKey] = _captchaResponse;
|
||||
}
|
||||
if (_deleteAttributes) {
|
||||
postBody[kDeleteAttributesKey] = _deleteAttributes;
|
||||
}
|
||||
if (_deleteProviders) {
|
||||
postBody[kDeleteProvidersKey] = _deleteProviders;
|
||||
}
|
||||
if (_returnSecureToken) {
|
||||
postBody[kReturnSecureTokenKey] = @YES;
|
||||
}
|
||||
if (self.tenantID) {
|
||||
postBody[kTenantIDKey] = self.tenantID;
|
||||
}
|
||||
return [postBody copy];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/FIRAuthRPCResponse.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @class FIRSetAccountInfoResponseProviderUserInfo
|
||||
@brief Represents the provider user info part of the response from the setAccountInfo endpoint.
|
||||
@see https://developers.google.com/identity/toolkit/web/reference/relyingparty/setAccountInfo
|
||||
*/
|
||||
@interface FIRSetAccountInfoResponseProviderUserInfo : NSObject
|
||||
|
||||
/** @property providerID
|
||||
@brief The ID of the identity provider.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSString *providerID;
|
||||
|
||||
/** @property displayName
|
||||
@brief The user's display name at the identity provider.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSString *displayName;
|
||||
|
||||
/** @property photoURL
|
||||
@brief The user's photo URL at the identity provider.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSURL *photoURL;
|
||||
|
||||
/** @fn init
|
||||
@brief Please use initWithDictionary:
|
||||
*/
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
/** @fn initWithAPIKey:
|
||||
@brief Designated initializer.
|
||||
@param dictionary The provider user info data from endpoint.
|
||||
*/
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dictionary NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@end
|
||||
|
||||
/** @class FIRSetAccountInfoResponse
|
||||
@brief Represents the response from the setAccountInfo endpoint.
|
||||
@see https://developers.google.com/identity/toolkit/web/reference/relyingparty/setAccountInfo
|
||||
*/
|
||||
@interface FIRSetAccountInfoResponse : NSObject <FIRAuthRPCResponse>
|
||||
|
||||
/** @property email
|
||||
@brief The email or the user.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSString *email;
|
||||
|
||||
/** @property displayName
|
||||
@brief The display name of the user.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSString *displayName;
|
||||
|
||||
/** @property providerUserInfo
|
||||
@brief The user's profiles at the associated identity providers.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable)
|
||||
NSArray<FIRSetAccountInfoResponseProviderUserInfo *> *providerUserInfo;
|
||||
|
||||
/** @property IDToken
|
||||
@brief Either an authorization code suitable for performing an STS token exchange, or the
|
||||
access token from Secure Token Service, depending on whether @c returnSecureToken is set
|
||||
on the request.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSString *IDToken;
|
||||
|
||||
/** @property approximateExpirationDate
|
||||
@brief The approximate expiration date of the access token.
|
||||
*/
|
||||
@property(nonatomic, copy, readonly, nullable) NSDate *approximateExpirationDate;
|
||||
|
||||
/** @property refreshToken
|
||||
@brief The refresh token from Secure Token Service.
|
||||
*/
|
||||
@property(nonatomic, strong, readonly, nullable) NSString *refreshToken;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/RPC/FIRSetAccountInfoResponse.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation FIRSetAccountInfoResponseProviderUserInfo
|
||||
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dictionary {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_providerID = [dictionary[@"providerId"] copy];
|
||||
_displayName = [dictionary[@"displayName"] copy];
|
||||
NSString *photoURL = dictionary[@"photoUrl"];
|
||||
if (photoURL) {
|
||||
_photoURL = [NSURL URLWithString:photoURL];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation FIRSetAccountInfoResponse
|
||||
|
||||
- (BOOL)setWithDictionary:(NSDictionary *)dictionary error:(NSError *_Nullable *_Nullable)error {
|
||||
_email = [dictionary[@"email"] copy];
|
||||
_displayName = [dictionary[@"displayName"] copy];
|
||||
_IDToken = [dictionary[@"idToken"] copy];
|
||||
_approximateExpirationDate =
|
||||
[dictionary[@"expiresIn"] isKindOfClass:[NSString class]]
|
||||
? [NSDate dateWithTimeIntervalSinceNow:[dictionary[@"expiresIn"] doubleValue]]
|
||||
: nil;
|
||||
_refreshToken = [dictionary[@"refreshToken"] copy];
|
||||
NSArray<NSDictionary *> *providerUserInfoData = dictionary[@"providerUserInfo"];
|
||||
if (providerUserInfoData) {
|
||||
NSMutableArray<FIRSetAccountInfoResponseProviderUserInfo *> *providerUserInfoArray =
|
||||
[NSMutableArray arrayWithCapacity:providerUserInfoData.count];
|
||||
for (NSDictionary *dictionary in providerUserInfoData) {
|
||||
[providerUserInfoArray addObject:[[FIRSetAccountInfoResponseProviderUserInfo alloc]
|
||||
initWithDictionary:dictionary]];
|
||||
}
|
||||
_providerUserInfo = [providerUserInfoArray copy];
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright 2018 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 "FirebaseAuth/Sources/Backend/FIRAuthRPCRequest.h"
|
||||
#import "FirebaseAuth/Sources/Backend/FIRIdentityToolkitRequest.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @class FIRSignInWithGameCenterRequest
|
||||
@brief The request to sign in with Game Center account
|
||||
*/
|
||||
@interface FIRSignInWithGameCenterRequest : FIRIdentityToolkitRequest <FIRAuthRPCRequest>
|
||||
|
||||
/** @property playerID
|
||||
@brief The playerID to verify.
|
||||
*/
|
||||
@property(nonatomic, copy) NSString *playerID;
|
||||
|
||||
/** @property publicKeyURL
|
||||
@brief The URL for the public encryption key.
|
||||
*/
|
||||
@property(nonatomic, copy) NSURL *publicKeyURL;
|
||||
|
||||
/** @property signature
|
||||
@brief The verification signature data generated by Game Center.
|
||||
*/
|
||||
@property(nonatomic, copy) NSData *signature;
|
||||
|
||||
/** @property salt
|
||||
@brief A random strong used to compute the hash and keep it randomized.
|
||||
*/
|
||||
@property(nonatomic, copy) NSData *salt;
|
||||
|
||||
/** @property timestamp
|
||||
@brief The date and time that the signature was created.
|
||||
*/
|
||||
@property(nonatomic, assign) uint64_t timestamp;
|
||||
|
||||
/** @property accessToken
|
||||
@brief The STS Access Token for the authenticated user, only needed for linking the user.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSString *accessToken;
|
||||
|
||||
/** @property displayName
|
||||
@brief The display name of the local Game Center player.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSString *displayName;
|
||||
|
||||
/** @fn initWithEndpoint:requestConfiguration:
|
||||
@brief Please use initWithPlayerID:publicKeyURL:signature:salt:timestamp:requestConfiguration:.
|
||||
*/
|
||||
- (nullable instancetype)initWithEndpoint:(NSString *)endpoint
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
|
||||
NS_UNAVAILABLE;
|
||||
|
||||
/** @fn initWithPlayerID:publicKeyURL:signature:salt:timestamp:displayName:requestConfiguration:
|
||||
@brief Designated initializer.
|
||||
@param playerID The ID of the Game Center player.
|
||||
@param publicKeyURL The URL for the public encryption key.
|
||||
@param signature The verification signature generated.
|
||||
@param salt A random string used to compute the hash and keep it randomized.
|
||||
@param timestamp The date and time that the signature was created.
|
||||
@param displayName The display name of the Game Center player.
|
||||
*/
|
||||
- (nullable instancetype)initWithPlayerID:(NSString *)playerID
|
||||
publicKeyURL:(NSURL *)publicKeyURL
|
||||
signature:(NSData *)signature
|
||||
salt:(NSData *)salt
|
||||
timestamp:(uint64_t)timestamp
|
||||
displayName:(NSString *)displayName
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
|
||||
NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright 2018 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 "FirebaseAuth/Sources/Backend/RPC/FIRSignInWithGameCenterRequest.h"
|
||||
|
||||
#import "FirebaseAuth/Sources/Utilities/NSData+FIRBase64.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @var kSignInWithGameCenterEndPoint
|
||||
@brief The "SignInWithGameCenter" endpoint.
|
||||
*/
|
||||
static NSString *const kSignInWithGameCenterEndPoint = @"signInWithGameCenter";
|
||||
|
||||
@implementation FIRSignInWithGameCenterRequest
|
||||
|
||||
- (nullable instancetype)initWithPlayerID:(NSString *)playerID
|
||||
publicKeyURL:(NSURL *)publicKeyURL
|
||||
signature:(NSData *)signature
|
||||
salt:(NSData *)salt
|
||||
timestamp:(uint64_t)timestamp
|
||||
displayName:(NSString *)displayName
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration {
|
||||
self = [super initWithEndpoint:kSignInWithGameCenterEndPoint
|
||||
requestConfiguration:requestConfiguration];
|
||||
if (self) {
|
||||
_playerID = playerID;
|
||||
_publicKeyURL = [publicKeyURL copy];
|
||||
_signature = [signature copy];
|
||||
_salt = [salt copy];
|
||||
_timestamp = timestamp;
|
||||
_displayName = displayName;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - FIRAuthRPCRequest
|
||||
|
||||
- (nullable id)unencodedHTTPRequestBodyWithError:(NSError *__autoreleasing _Nullable *)error {
|
||||
NSMutableDictionary *postBody = [NSMutableDictionary dictionary];
|
||||
if (_playerID) {
|
||||
postBody[@"playerId"] = _playerID;
|
||||
}
|
||||
if (_publicKeyURL) {
|
||||
postBody[@"publicKeyUrl"] = _publicKeyURL.absoluteString;
|
||||
}
|
||||
if (_signature) {
|
||||
postBody[@"signature"] = [_signature fir_base64URLEncodedStringWithOptions:0];
|
||||
}
|
||||
if (_salt) {
|
||||
postBody[@"salt"] = [_salt fir_base64URLEncodedStringWithOptions:0];
|
||||
}
|
||||
if (_timestamp != 0) {
|
||||
postBody[@"timestamp"] = [NSNumber numberWithUnsignedLongLong:_timestamp];
|
||||
}
|
||||
if (_accessToken) {
|
||||
postBody[@"idToken"] = _accessToken;
|
||||
}
|
||||
if (_displayName) {
|
||||
postBody[@"displayName"] = _displayName;
|
||||
}
|
||||
return [postBody copy];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2018 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 "FirebaseAuth/Sources/Backend/FIRAuthRPCResponse.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FIRSignInWithGameCenterResponse : NSObject <FIRAuthRPCResponse>
|
||||
|
||||
/** @property IDToken
|
||||
@breif Either an authorization code suitable for performing an STS token exchange, or the access
|
||||
token from Secure Token Service, depending on whether @c returnSecureToken is set on the
|
||||
request.
|
||||
*/
|
||||
@property(nonatomic, copy, readonly, nullable) NSString *IDToken;
|
||||
|
||||
/** @property refreshToken
|
||||
@breif @breif The refresh token from Secure Token Service.
|
||||
*/
|
||||
@property(nonatomic, copy, readonly, nullable) NSString *refreshToken;
|
||||
|
||||
/** @property localID
|
||||
@breif @breif The Firebase Auth user ID.
|
||||
*/
|
||||
@property(nonatomic, copy, readonly, nullable) NSString *localID;
|
||||
|
||||
/** @property playerID
|
||||
@breif @breif The verified player ID.
|
||||
*/
|
||||
@property(nonatomic, copy, readonly, nullable) NSString *playerID;
|
||||
|
||||
/** @property approximateExpirationDate
|
||||
@breif The approximate expiration date of the access token.
|
||||
*/
|
||||
@property(nonatomic, copy, readonly, nullable) NSDate *approximateExpirationDate;
|
||||
|
||||
/** @property isNewUser
|
||||
@breif Flag indicating that the user signing in is a new user and not a returning user.
|
||||
*/
|
||||
@property(nonatomic, assign) BOOL isNewUser;
|
||||
|
||||
/** @property displayName
|
||||
@breif The user's Game Center display name.
|
||||
*/
|
||||
@property(nonatomic, copy, readonly, nullable) NSString *displayName;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2018 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 "FirebaseAuth/Sources/Backend/RPC/FIRSignInWithGameCenterResponse.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation FIRSignInWithGameCenterResponse
|
||||
|
||||
- (BOOL)setWithDictionary:(NSDictionary *)dictionary error:(NSError *_Nullable *_Nullable)error {
|
||||
_IDToken = [dictionary[@"idToken"] copy];
|
||||
_refreshToken = [dictionary[@"refreshToken"] copy];
|
||||
_localID = [dictionary[@"localId"] copy];
|
||||
_approximateExpirationDate = nil;
|
||||
if ([dictionary[@"expiresIn"] isKindOfClass:[NSString class]]) {
|
||||
_approximateExpirationDate =
|
||||
[NSDate dateWithTimeIntervalSinceNow:[dictionary[@"expiresIn"] integerValue]];
|
||||
}
|
||||
_playerID = [dictionary[@"playerId"] copy];
|
||||
_isNewUser = [dictionary[@"isNewUser"] boolValue];
|
||||
_displayName = [dictionary[@"displayName"] copy];
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/FIRAuthRPCRequest.h"
|
||||
#import "FirebaseAuth/Sources/Backend/FIRIdentityToolkitRequest.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FIRSignUpNewUserRequest : FIRIdentityToolkitRequest <FIRAuthRPCRequest>
|
||||
|
||||
/** @property email
|
||||
@brief The email of the user.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSString *email;
|
||||
|
||||
/** @property password
|
||||
@brief The password inputed by the user.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSString *password;
|
||||
|
||||
/** @property displayName
|
||||
@brief The password inputed by the user.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSString *displayName;
|
||||
|
||||
/** @property returnSecureToken
|
||||
@brief Whether the response should return access token and refresh token directly.
|
||||
@remarks The default value is @c YES .
|
||||
*/
|
||||
@property(nonatomic, assign) BOOL returnSecureToken;
|
||||
|
||||
/** @fn initWithEndpoint:requestConfiguration:
|
||||
@brief Please use initWithAPIKey:email:password:displayName:requestConfiguration instead.
|
||||
*/
|
||||
- (nullable instancetype)initWithEndpoint:(NSString *)endpoint
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
|
||||
NS_UNAVAILABLE;
|
||||
|
||||
/** @fn initWithEndpoint:requestConfiguration:
|
||||
@brief initializer for anonymous sign-in.
|
||||
*/
|
||||
- (nullable instancetype)initWithRequestConfiguration:
|
||||
(FIRAuthRequestConfiguration *)requestConfiguration;
|
||||
|
||||
/** @fn initWithAPIKey:email:password:displayName:requestConfiguration
|
||||
@brief Designated initializer.
|
||||
@param requestConfiguration An object containing configurations to be added to the request.
|
||||
*/
|
||||
- (nullable instancetype)initWithEmail:(nullable NSString *)email
|
||||
password:(nullable NSString *)password
|
||||
displayName:(nullable NSString *)displayName
|
||||
requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
|
||||
NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* 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 "FirebaseAuth/Sources/Backend/RPC/FIRSignUpNewUserRequest.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** @var kSignupNewUserEndpoint
|
||||
@brief The "SingupNewUserEndpoint" endpoint.
|
||||
*/
|
||||
static NSString *const kSignupNewUserEndpoint = @"signupNewUser";
|
||||
|
||||
/** @var kEmailKey
|
||||
@brief The key for the "email" value in the request.
|
||||
*/
|
||||
static NSString *const kEmailKey = @"email";
|
||||
|
||||
/** @var kPasswordKey
|
||||
@brief The key for the "password" value in the request.
|
||||
*/
|
||||
static NSString *const kPasswordKey = @"password";
|
||||
|
||||
/** @var kDisplayNameKey
|
||||
@brief The key for the "kDisplayName" value in the request.
|
||||
*/
|
||||
static NSString *const kDisplayNameKey = @"displayName";
|
||||
|
||||
/** @var kReturnSecureTokenKey
|
||||
@brief The key for the "returnSecureToken" value in the request.
|
||||
*/
|
||||
static NSString *const kReturnSecureTokenKey = @"returnSecureToken";
|
||||
|
||||
/** @var kTenantIDKey
|
||||
@brief The key for the tenant id value in the request.
|
||||
*/
|
||||
static NSString *const kTenantIDKey = @"tenantId";
|
||||
|
||||
@implementation FIRSignUpNewUserRequest
|
||||
|
||||
- (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];
|
||||
_displayName = [displayName copy];
|
||||
_returnSecureToken = YES;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithRequestConfiguration:
|
||||
(FIRAuthRequestConfiguration *)requestConfiguration {
|
||||
self = [self initWithEmail:nil
|
||||
password:nil
|
||||
displayName:nil
|
||||
requestConfiguration:requestConfiguration];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (nullable id)unencodedHTTPRequestBodyWithError:(NSError *_Nullable *_Nullable)error {
|
||||
NSMutableDictionary *postBody = [NSMutableDictionary dictionary];
|
||||
if (_email) {
|
||||
postBody[kEmailKey] = _email;
|
||||
}
|
||||
if (_password) {
|
||||
postBody[kPasswordKey] = _password;
|
||||
}
|
||||
if (_displayName) {
|
||||
postBody[kDisplayNameKey] = _displayName;
|
||||
}
|
||||
if (_returnSecureToken) {
|
||||
postBody[kReturnSecureTokenKey] = @YES;
|
||||
}
|
||||
if (self.tenantID) {
|
||||
postBody[kTenantIDKey] = self.tenantID;
|
||||
}
|
||||
return [postBody copy];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user