FIRDatabaseConnectionContextProvider.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright 2021 Google LLC
  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 "FirebaseDatabase/Sources/Api/Private/FTypedefs_Private.h"
  18. #import "FirebaseDatabase/Sources/Utilities/FTypedefs.h"
  19. @protocol FIRAppCheckInterop;
  20. @protocol FIRAuthInterop;
  21. NS_ASSUME_NONNULL_BEGIN
  22. @interface FIRDatabaseConnectionContext : NSObject
  23. /// Auth token if available.
  24. @property(nonatomic, nullable) NSString *authToken;
  25. /// App check token if available.
  26. @property(nonatomic, nullable) NSString *appCheckToken;
  27. - (instancetype)initWithAuthToken:(nullable NSString *)authToken
  28. appCheckToken:(nullable NSString *)appCheckToken;
  29. @end
  30. @protocol FIRDatabaseConnectionContextProvider <NSObject>
  31. - (void)
  32. fetchContextForcingRefresh:(BOOL)forceRefresh
  33. withCallback:
  34. (void (^)(FIRDatabaseConnectionContext *_Nullable context,
  35. NSError *_Nullable error))callback;
  36. /// Adds a listener to the Auth token updates.
  37. /// @param listener A block that will be invoked each time the Auth token is
  38. /// updated.
  39. - (void)listenForAuthTokenChanges:(fbt_void_nsstring)listener;
  40. /// Adds a listener to the FAC token updates.
  41. /// @param listener A block that will be invoked each time the FAC token is
  42. /// updated.
  43. - (void)listenForAppCheckTokenChanges:(fbt_void_nsstring)listener;
  44. @end
  45. @interface FIRDatabaseConnectionContextProvider
  46. : NSObject <FIRDatabaseConnectionContextProvider>
  47. + (id<FIRDatabaseConnectionContextProvider>)
  48. contextProviderWithAuth:(nullable id<FIRAuthInterop>)auth
  49. appCheck:(nullable id<FIRAppCheckInterop>)appCheck;
  50. - (instancetype)init NS_UNAVAILABLE;
  51. @end
  52. NS_ASSUME_NONNULL_END