GIDSignInInternalOptions.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. #if __has_include(<UIKit/UIKit.h>)
  18. #import <UIKit/UIKit.h>
  19. #elif __has_include(<AppKit/AppKit.h>)
  20. #import <AppKit/AppKit.h>
  21. #endif
  22. #import "GoogleSignIn/Sources/GIDSignIn_Private.h"
  23. @class GIDConfiguration;
  24. @class GIDSignInResult;
  25. NS_ASSUME_NONNULL_BEGIN
  26. /// The options used internally for aspects of the sign-in flow.
  27. @interface GIDSignInInternalOptions : NSObject
  28. /// Whether interaction with user is allowed at all.
  29. @property(nonatomic, readonly) BOOL interactive;
  30. /// Whether the sign-in is a continuation of the previous one.
  31. @property(nonatomic, readonly) BOOL continuation;
  32. /// Whether the sign-in is an addScopes flow. NO means it is a sign in flow.
  33. @property(nonatomic, readonly) BOOL addScopesFlow;
  34. /// The extra parameters used in the sign-in URL.
  35. @property(nonatomic, readonly, nullable) NSDictionary *extraParams;
  36. /// The configuration to use during the flow.
  37. @property(nonatomic, readonly, nullable) GIDConfiguration *configuration;
  38. #if TARGET_OS_IOS || TARGET_OS_MACCATALYST
  39. /// The view controller to use during the flow.
  40. @property(nonatomic, readonly, weak, nullable) UIViewController *presentingViewController;
  41. #elif TARGET_OS_OSX
  42. /// The window to use during the flow.
  43. @property(nonatomic, readonly, weak, nullable) NSWindow *presentingWindow;
  44. #endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
  45. /// The completion block to be called at the completion of the flow.
  46. @property(nonatomic, readonly, nullable) GIDSignInCompletion completion;
  47. /// The scopes to be used during the flow.
  48. @property(nonatomic, copy, nullable) NSArray<NSString *> *scopes;
  49. /// The login hint to be used during the flow.
  50. @property(nonatomic, copy, nullable) NSString *loginHint;
  51. /// A cryptographically random value used to associate a Client session with an ID Token,
  52. /// and to mitigate replay attacks.
  53. @property(nonatomic, readonly, copy, nullable) NSString *nonce;
  54. /// Creates the default options.
  55. #if TARGET_OS_IOS || TARGET_OS_MACCATALYST
  56. + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
  57. presentingViewController:(nullable UIViewController *)presentingViewController
  58. loginHint:(nullable NSString *)loginHint
  59. addScopesFlow:(BOOL)addScopesFlow
  60. completion:(nullable GIDSignInCompletion)completion;
  61. + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
  62. presentingViewController:(nullable UIViewController *)presentingViewController
  63. loginHint:(nullable NSString *)loginHint
  64. addScopesFlow:(BOOL)addScopesFlow
  65. scopes:(nullable NSArray *)scopes
  66. nonce:(nullable NSString *)nonce
  67. completion:(nullable GIDSignInCompletion)completion;
  68. #elif TARGET_OS_OSX
  69. + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
  70. presentingWindow:(nullable NSWindow *)presentingWindow
  71. loginHint:(nullable NSString *)loginHint
  72. addScopesFlow:(BOOL)addScopesFlow
  73. completion:(nullable GIDSignInCompletion)completion;
  74. + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
  75. presentingWindow:(nullable NSWindow *)presentingWindow
  76. loginHint:(nullable NSString *)loginHint
  77. addScopesFlow:(BOOL)addScopesFlow
  78. scopes:(nullable NSArray *)scopes
  79. nonce:(nullable NSString *)nonce
  80. completion:(nullable GIDSignInCompletion)completion;
  81. #endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
  82. /// Creates the options to sign in silently.
  83. + (instancetype)silentOptionsWithCompletion:(GIDSignInCompletion)completion;
  84. /// Creates options with the same values as the receiver, except for the "extra parameters", and
  85. /// continuation flag, which are replaced by the arguments passed to this method.
  86. - (instancetype)optionsWithExtraParameters:(NSDictionary *)extraParams
  87. forContinuation:(BOOL)continuation;
  88. @end
  89. NS_ASSUME_NONNULL_END