GIDSignInInternalOptions.h 5.4 KB

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