You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.5 KiB

5 years ago
5 years ago
5 years ago
  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 "FIRInstanceIDTokenOperation.h"
  17. #import "FIRInstanceIDUtilities.h"
  18. @class FIRInstanceIDURLQueryItem;
  19. NS_ASSUME_NONNULL_BEGIN
  20. @interface FIRInstanceIDTokenOperation (Private)
  21. @property(atomic, strong) NSURLSessionDataTask *dataTask;
  22. @property(readonly, strong)
  23. NSMutableArray<FIRInstanceIDTokenOperationCompletion> *completionHandlers;
  24. // For testing only
  25. @property(nonatomic, readwrite, copy) FIRInstanceIDURLRequestTestBlock testBlock;
  26. + (NSURLSession *)sharedURLSession;
  27. #pragma mark - Initialization
  28. - (instancetype)initWithAction:(FIRInstanceIDTokenAction)action
  29. forAuthorizedEntity:(nullable NSString *)authorizedEntity
  30. scope:(NSString *)scope
  31. options:(nullable NSDictionary<NSString *, NSString *> *)options
  32. checkinPreferences:(FIRInstanceIDCheckinPreferences *)checkinPreferences
  33. instanceID:(NSString *)instanceID;
  34. #pragma mark - Request Construction
  35. + (NSMutableArray<FIRInstanceIDURLQueryItem *> *)standardQueryItemsWithDeviceID:(NSString *)deviceID
  36. scope:(NSString *)scope;
  37. - (NSMutableURLRequest *)tokenRequest;
  38. - (NSArray<FIRInstanceIDURLQueryItem *> *)queryItemsWithInstanceID:(NSString *)instanceID;
  39. #pragma mark - HTTP Headers
  40. /**
  41. * Given a valid checkin preferences object, it will return a string that can be used
  42. * in the "Authorization" HTTP header to authenticate this request.
  43. *
  44. * @param checkin The valid checkin preferences object, with a deviceID and secretToken.
  45. */
  46. + (NSString *)HTTPAuthHeaderFromCheckin:(FIRInstanceIDCheckinPreferences *)checkin;
  47. #pragma mark - Result
  48. - (void)finishWithResult:(FIRInstanceIDTokenOperationResult)result
  49. token:(nullable NSString *)token
  50. error:(nullable NSError *)error;
  51. #pragma mark - Methods to override
  52. - (void)performTokenOperation;
  53. @end
  54. NS_ASSUME_NONNULL_END