GIDAuthentication.m 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright 2022 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 "GoogleSignIn/Sources/GIDAuthentication.h"
  17. #ifdef SWIFT_PACKAGE
  18. @import AppAuth;
  19. #else
  20. #import <AppAuth/AppAuth.h>
  21. #endif
  22. NS_ASSUME_NONNULL_BEGIN
  23. static NSString *const kAuthStateKey = @"authState";
  24. @implementation GIDAuthentication
  25. - (instancetype)initWithAuthState:(OIDAuthState *)authState {
  26. self = [super init];
  27. if (self) {
  28. _authState = authState;
  29. }
  30. return self;
  31. }
  32. #pragma mark - NSSecureCoding
  33. + (BOOL)supportsSecureCoding {
  34. return YES;
  35. }
  36. - (nullable instancetype)initWithCoder:(NSCoder *)decoder {
  37. self = [super init];
  38. if (self) {
  39. _authState = [decoder decodeObjectOfClass:[OIDAuthState class] forKey:kAuthStateKey];
  40. }
  41. return self;
  42. }
  43. - (void)encodeWithCoder:(NSCoder *)encoder {
  44. [encoder encodeObject:self.authState forKey:kAuthStateKey];
  45. }
  46. @end
  47. NS_ASSUME_NONNULL_END