GIDSignInInternalOptions.h 6.3 KB

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