FIRStartPasskeyEnrollmentRequest.m 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright 2023 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/LICENSE2.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 "FirebaseAuth/Sources/Backend/RPC/FIRStartPasskeyEnrollmentRequest.h"
  17. NS_ASSUME_NONNULL_BEGIN
  18. /**
  19. @var kStartPasskeyEnrollmentEndPoint
  20. @brief GCIP endpoint for startPasskeyEnrollment rpc
  21. */
  22. static NSString *const kStartPasskeyEnrollmentEndPoint = @"accounts/passkeyEnrollment:start";
  23. /**
  24. @var kTenantIDKey
  25. @brief The key for the tenant id value in the request.
  26. */
  27. static NSString *const kTenantIDKey = @"tenantId";
  28. /**
  29. @var kIDToken
  30. @brief The key for idToken value in the request.
  31. */
  32. static NSString *const kIDToken = @"idToken";
  33. @implementation FIRStartPasskeyEnrollmentRequest
  34. - (nullable instancetype)initWithIDToken:(NSString *)IDToken
  35. requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration {
  36. self = [super initWithEndpoint:kStartPasskeyEnrollmentEndPoint
  37. requestConfiguration:requestConfiguration];
  38. if (self) {
  39. _IDToken = IDToken;
  40. self.useIdentityPlatform = YES;
  41. self.useStaging = NO;
  42. }
  43. return self;
  44. }
  45. - (nullable id)unencodedHTTPRequestBodyWithError:(NSError *__autoreleasing _Nullable *)error {
  46. NSMutableDictionary *postBody = [NSMutableDictionary dictionary];
  47. if (_IDToken) {
  48. postBody[kIDToken] = _IDToken;
  49. }
  50. if (self.tenantID) {
  51. postBody[kTenantIDKey] = self.tenantID;
  52. }
  53. return [postBody copy];
  54. }
  55. @end
  56. NS_ASSUME_NONNULL_END