FIRAuthStoredUserManager.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Copyright 2019 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. #import "FirebaseAuth/Sources/Public/FirebaseAuth/FIRUser.h"
  18. #import "FirebaseAuth/Sources/Storage/FIRAuthKeychainServices.h"
  19. #import "FirebaseAuth/Sources/Storage/FIRAuthUserDefaults.h"
  20. NS_ASSUME_NONNULL_BEGIN
  21. @interface FIRAuthStoredUserManager : NSObject
  22. /** @property keychain
  23. @brief The mediator object to access to the system Keychain services.
  24. */
  25. @property(readonly, nonatomic, strong) FIRAuthKeychainServices *keychainServices;
  26. /** @property userDefaults
  27. @brief The mediator object to access to the system User Defaults services.
  28. */
  29. @property(readonly, nonatomic, strong) FIRAuthUserDefaults *userDefaults;
  30. /** @fn init
  31. @brief The default initializer is disabled.
  32. */
  33. - (instancetype)init NS_UNAVAILABLE;
  34. /** @fn initWithServiceName:
  35. @brief The designated initializer.
  36. @param serviceName The service name to initialize with.
  37. */
  38. - (instancetype)initWithServiceName:(NSString *)serviceName NS_DESIGNATED_INITIALIZER;
  39. /** @fn getStoredUserAccessGroupWithError:
  40. @brief Get the user access group stored locally.
  41. @param outError Return value for any error which occurs.
  42. */
  43. - (nullable NSString *)getStoredUserAccessGroupWithError:(NSError *_Nullable *_Nullable)outError;
  44. /** @fn setStoredUserAccessGroup:error:
  45. @brief The setter of the user access group stored locally.
  46. @param accessGroup The access group to be set.
  47. @param outError Return value for any error which occurs.
  48. */
  49. - (BOOL)setStoredUserAccessGroup:(NSString *_Nullable)accessGroup
  50. error:(NSError *_Nullable *_Nullable)outError;
  51. /** @fn getStoredUserForAccessGroup:projectID:error:
  52. @brief The getter of the user stored locally.
  53. @param accessGroup The access group to retrieve the user from.
  54. @param shareAuthStateAcrossDevices If true, the keychain will be synced across the end-user's
  55. iCloud.
  56. @param projectIdentifier An identifier of the project that the user associates with. Currently,
  57. we use API KEY.
  58. @param outError Return value for any error which occurs.
  59. */
  60. - (nullable FIRUser *)getStoredUserForAccessGroup:(NSString *)accessGroup
  61. shareAuthStateAcrossDevices:(BOOL)shareAuthStateAcrossDevices
  62. projectIdentifier:(NSString *)projectIdentifier
  63. error:(NSError *_Nullable *_Nullable)outError;
  64. /** @fn setStoredUser:forAccessGroup:projectID:error:
  65. @brief The setter of the user stored locally.
  66. @param user The user to be stored.
  67. @param accessGroup The access group to store the user in.
  68. @param shareAuthStateAcrossDevices If true, the keychain will be synced across the end-user's
  69. iCloud.
  70. @param projectIdentifier An identifier of the project that the user associates with. Currently,
  71. we use API KEY.
  72. @param outError Return value for any error which occurs.
  73. */
  74. - (BOOL)setStoredUser:(FIRUser *)user
  75. forAccessGroup:(NSString *)accessGroup
  76. shareAuthStateAcrossDevices:(BOOL)shareAuthStateAcrossDevices
  77. projectIdentifier:(NSString *)projectIdentifier
  78. error:(NSError *_Nullable *_Nullable)outError;
  79. /** @fn removeStoredUserForAccessGroup:projectID:error:
  80. @brief Remove the user that stored locally.
  81. @param accessGroup The access group to remove the user from.
  82. @param shareAuthStateAcrossDevices If true, the keychain will be synced across the end-user's
  83. iCloud.
  84. @param projectIdentifier An identifier of the project that the user associates with. Currently,
  85. we use API KEY.
  86. @param outError Return value for any error which occurs.
  87. */
  88. - (BOOL)removeStoredUserForAccessGroup:(NSString *)accessGroup
  89. shareAuthStateAcrossDevices:(BOOL)shareAuthStateAcrossDevices
  90. projectIdentifier:(NSString *)projectIdentifier
  91. error:(NSError *_Nullable *_Nullable)outError;
  92. @end
  93. NS_ASSUME_NONNULL_END