FIRStartPasskeySignInResponse.m 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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/FIRStartPasskeySignInResponse.h"
  17. /**
  18. @var kOptionsKey
  19. @brief Parameters specified for the authenticator to sign a challenge.
  20. */
  21. static const NSString *kOptionsKey = @"credentialRequestOptions";
  22. /**
  23. @var kRpIdKey
  24. @brief The relying party identifier.
  25. */
  26. static const NSString *kRpIdKey = @"rpId";
  27. /**
  28. @var kChallengeKey
  29. @brief The name of the field in the response JSON for challenge.
  30. */
  31. static const NSString *kChallengeKey = @"challenge";
  32. @implementation FIRStartPasskeySignInResponse
  33. - (BOOL)setWithDictionary:(nonnull NSDictionary *)dictionary
  34. error:(NSError *__autoreleasing _Nullable *_Nullable)error {
  35. if (dictionary[kOptionsKey] == nil) {
  36. return NO;
  37. }
  38. if (dictionary[kOptionsKey][kRpIdKey] == nil) {
  39. return NO;
  40. }
  41. if (dictionary[kOptionsKey][kChallengeKey] == nil) {
  42. return NO;
  43. }
  44. _rpID = dictionary[kOptionsKey][kRpIdKey];
  45. _challenge = dictionary[kOptionsKey][kChallengeKey];
  46. return YES;
  47. }
  48. @end