Bläddra i källkod

Renamed to throughout the code.

Akshat Gandhi 6 månader sedan
förälder
incheckning
93c5b54dce

+ 5 - 5
GoogleSignIn/Sources/GIDTokenClaim.m → GoogleSignIn/Sources/GIDClaim.m

@@ -14,19 +14,19 @@
  * limitations under the License.
  */
 
-#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDTokenClaim.h"
+#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDClaim.h"
 
 NSString * const kAuthTimeClaimName = @"auth_time";
 
 // Private interface to declare the internal initializer
-@interface GIDTokenClaim ()
+@interface GIDClaim ()
 
 - (instancetype)initWithName:(NSString *)name
                    essential:(BOOL)essential NS_DESIGNATED_INITIALIZER;
 
 @end
 
-@implementation GIDTokenClaim
+@implementation GIDClaim
 
 // Private designated initializer
 - (instancetype)initWithName:(NSString *)name essential:(BOOL)essential {
@@ -57,12 +57,12 @@ NSString * const kAuthTimeClaimName = @"auth_time";
   }
 
   // 2. Check if the other object is not a GIDTokenClaim instance.
-  if (![object isKindOfClass:[GIDTokenClaim class]]) {
+  if (![object isKindOfClass:[GIDClaim class]]) {
     return NO;
   }
 
   // 3. Compare the properties that define equality.
-  GIDTokenClaim *other = (GIDTokenClaim *)object;
+  GIDClaim *other = (GIDClaim *)object;
   return [self.name isEqualToString:other.name] &&
          self.isEssential == other.isEssential;
 }

+ 9 - 9
GoogleSignIn/Sources/GIDTokenClaimsInternalOptions.h → GoogleSignIn/Sources/GIDClaimsInternalOptions.h

@@ -16,21 +16,21 @@
 
 #import <Foundation/Foundation.h>
 
-@class GIDTokenClaim;
+@class GIDClaim;
 
 NS_ASSUME_NONNULL_BEGIN
 
-extern NSString *const kGIDTokenClaimErrorDescription;
-extern NSString *const kGIDTokenClaimEssentialPropertyKeyName;
-extern NSString *const kGIDTokenClaimKeyName;
+extern NSString *const kGIDClaimErrorDescription;
+extern NSString *const kGIDClaimEssentialPropertyKeyName;
+extern NSString *const kGIDClaimKeyName;
 
 @protocol GIDJSONSerializer;
 
 /**
- * An internal utility class for processing and serializing the `NSSet` of `GIDTokenClaim` objects
+ * An internal utility class for processing and serializing the `NSSet` of `GIDClaim` objects
  * into the `JSON` format required for an `OIDAuthorizationRequest`.
  */
-@interface GIDTokenClaimsInternalOptions : NSObject
+@interface GIDClaimsInternalOptions : NSObject
 
 - (instancetype)init;
 
@@ -38,16 +38,16 @@ extern NSString *const kGIDTokenClaimKeyName;
     (id<GIDJSONSerializer>)jsonSerializer NS_DESIGNATED_INITIALIZER;
 
 /**
- * Processes the `NSSet` of `GIDTokenClaim` objects, handling ambiguous claims,
+ * Processes the `NSSet` of `GIDClaim` objects, handling ambiguous claims,
  * and returns a `JSON` string.
  *
- * @param claims The `NSSet` of `GIDTokenClaim` objects provided by the developer.
+ * @param claims The `NSSet` of `GIDClaim` objects provided by the developer.
  * @param error A pointer to an `NSError` object to be populated if an error occurs (e.g., if a
  * claim is requested as both essential and non-essential).
  * @return A `JSON` string representing the claims request, or `nil` if the input is empty or an
  * error occurs.
  */
-- (nullable NSString *)validatedJSONStringForClaims:(nullable NSSet<GIDTokenClaim *> *)claims
+- (nullable NSString *)validatedJSONStringForClaims:(nullable NSSet<GIDClaim *> *)claims
                                               error:(NSError *_Nullable *_Nullable)error;
 
 @end

+ 17 - 17
GoogleSignIn/Sources/GIDTokenClaimsInternalOptions.m → GoogleSignIn/Sources/GIDClaimsInternalOptions.m

@@ -14,24 +14,24 @@
  * limitations under the License.
  */
 
-#import "GoogleSignIn/Sources/GIDTokenClaimsInternalOptions.h"
+#import "GoogleSignIn/Sources/GIDClaimsInternalOptions.h"
 
 #import "GoogleSignIn/Sources/GIDJSONSerializer/API/GIDJSONSerializer.h"
 #import "GoogleSignIn/Sources/GIDJSONSerializer/Implementation/GIDJSONSerializerImpl.h"
 #import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h"
-#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDTokenClaim.h"
+#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDClaim.h"
 
-NSString * const kGIDTokenClaimErrorDescription =
+NSString * const kGIDClaimErrorDescription =
     @"The claim was requested as both essential and non-essential. "
     @"Please provide only one version.";
-NSString * const kGIDTokenClaimEssentialPropertyKey = @"essential";
-NSString * const kGIDTokenClaimKeyName = @"id_token";
+NSString * const kGIDClaimEssentialPropertyKey = @"essential";
+NSString * const kGIDClaimKeyName = @"id_token";
 
-@interface GIDTokenClaimsInternalOptions ()
+@interface GIDClaimsInternalOptions ()
 @property(nonatomic, readonly) id<GIDJSONSerializer> jsonSerializer;
 @end
 
-@implementation GIDTokenClaimsInternalOptions
+@implementation GIDClaimsInternalOptions
 
 - (instancetype)init {
   return [self initWithJSONSerializer:[[GIDJSONSerializerImpl alloc] init]];
@@ -44,18 +44,18 @@ NSString * const kGIDTokenClaimKeyName = @"id_token";
   return self;
 }
 
-- (nullable NSString *)validatedJSONStringForClaims:(nullable NSSet<GIDTokenClaim *> *)claims
+- (nullable NSString *)validatedJSONStringForClaims:(nullable NSSet<GIDClaim *> *)claims
                                               error:(NSError *_Nullable *_Nullable)error {
   if (!claims || claims.count == 0) {
     return nil;
   }
 
   // === Step 1: Check for claims with ambiguous essential property. ===
-  NSMutableDictionary<NSString *, GIDTokenClaim *> *validTokenClaims =
+  NSMutableDictionary<NSString *, GIDClaim *> *validClaims =
     [[NSMutableDictionary alloc] init];
 
-  for (GIDTokenClaim *currentClaim in claims) {
-    GIDTokenClaim *existingClaim = validTokenClaims[currentClaim.name];
+  for (GIDClaim *currentClaim in claims) {
+    GIDClaim *existingClaim = validClaims[currentClaim.name];
 
     // Check for a conflict: a claim with the same name but different essentiality.
     if (existingClaim && existingClaim.isEssential != currentClaim.isEssential) {
@@ -63,26 +63,26 @@ NSString * const kGIDTokenClaimKeyName = @"id_token";
         *error = [NSError errorWithDomain:kGIDSignInErrorDomain
                                      code:kGIDSignInErrorCodeAmbiguousClaims
                                  userInfo:@{
-                                   NSLocalizedDescriptionKey:kGIDTokenClaimErrorDescription
+                                   NSLocalizedDescriptionKey:kGIDClaimErrorDescription
                                  }];
       }
       return nil;
     }
-    validTokenClaims[currentClaim.name] = currentClaim;
+    validClaims[currentClaim.name] = currentClaim;
   }
 
   // === Step 2: Build the dictionary structure required for OIDC JSON ===
   NSMutableDictionary<NSString *, NSDictionary *> *tokenClaimsDictionary =
     [[NSMutableDictionary alloc] init];
-  for (GIDTokenClaim *claim in validTokenClaims.allValues) {
+  for (GIDClaim *claim in validClaims.allValues) {
     if (claim.isEssential) {
-      tokenClaimsDictionary[claim.name] = @{ kGIDTokenClaimEssentialPropertyKey: @YES };
+      tokenClaimsDictionary[claim.name] = @{ kGIDClaimEssentialPropertyKey: @YES };
     } else {
-      tokenClaimsDictionary[claim.name] = @{ kGIDTokenClaimEssentialPropertyKey: @NO };
+      tokenClaimsDictionary[claim.name] = @{ kGIDClaimEssentialPropertyKey: @NO };
     }
   }
   NSDictionary<NSString *, id> *finalRequestDictionary =
-    @{ kGIDTokenClaimKeyName: tokenClaimsDictionary };
+    @{ kGIDClaimKeyName: tokenClaimsDictionary };
 
   // === Step 3: Serialize the final dictionary into a JSON string ===
   return [_jsonSerializer stringWithJSONObject:finalRequestDictionary error:error];

+ 38 - 38
GoogleSignIn/Sources/GIDSignIn.m

@@ -28,7 +28,7 @@
 #import "GoogleSignIn/Sources/GIDCallbackQueue.h"
 #import "GoogleSignIn/Sources/GIDScopes.h"
 #import "GoogleSignIn/Sources/GIDSignInCallbackSchemes.h"
-#import "GoogleSignIn/Sources/GIDTokenClaimsInternalOptions.h"
+#import "GoogleSignIn/Sources/GIDClaimsInternalOptions.h"
 #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 #import <AppCheckCore/GACAppCheckToken.h>
 #import "GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h"
@@ -138,7 +138,7 @@ static NSString *const kLoginHintParameter = @"login_hint";
 static NSString *const kHostedDomainParameter = @"hd";
 
 // Parameter for requesting the token claims.
-static NSString *const kTokenClaimsParameter = @"claims";
+static NSString *const kClaimsParameter = @"claims";
 
 // Parameters for auth and token exchange endpoints using App Attest.
 static NSString *const kClientAssertionParameter = @"client_assertion";
@@ -173,7 +173,7 @@ static NSString *const kConfigOpenIDRealmKey = @"GIDOpenIDRealm";
   // set when a sign-in flow is begun via |signInWithOptions:| when the options passed don't
   // represent a sign in continuation.
   GIDSignInInternalOptions *_currentOptions;
-  GIDTokenClaimsInternalOptions *_tokenClaimsInternalOptions;
+  GIDClaimsInternalOptions *_claimsInternalOptions;
 #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
   GIDAppCheck *_appCheck API_AVAILABLE(ios(14));
 #endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
@@ -293,40 +293,40 @@ static NSString *const kConfigOpenIDRealmKey = @"GIDOpenIDRealm";
                                       hint:hint
                           additionalScopes:additionalScopes
                                      nonce:nonce
-                               tokenClaims:nil
+                                    claims:nil
                                 completion:completion];
 }
 
 - (void)signInWithPresentingViewController:(UIViewController *)presentingViewController
-                               tokenClaims:(nullable NSSet<GIDTokenClaim *> *)tokenClaims
+                                    claims:(nullable NSSet<GIDClaim *> *)claims
                                 completion:(nullable GIDSignInCompletion)completion {
   [self signInWithPresentingViewController:presentingViewController
                                       hint:nil
-                               tokenClaims:tokenClaims
+                                    claims:claims
                                 completion:completion];
 }
 
 - (void)signInWithPresentingViewController:(UIViewController *)presentingViewController
                                       hint:(nullable NSString *)hint
-                               tokenClaims:(nullable NSSet<GIDTokenClaim *> *)tokenClaims
+                                    claims:(nullable NSSet<GIDClaim *> *)claims
                                 completion:(nullable GIDSignInCompletion)completion {
   [self signInWithPresentingViewController:presentingViewController
                                       hint:hint
                           additionalScopes:@[]
-                               tokenClaims:tokenClaims
+                                    claims:claims
                                 completion:completion];
 }
 
 - (void)signInWithPresentingViewController:(UIViewController *)presentingViewController
                                       hint:(nullable NSString *)hint
                           additionalScopes:(nullable NSArray<NSString *> *)additionalScopes
-                               tokenClaims:(nullable NSSet<GIDTokenClaim *> *)tokenClaims
+                                    claims:(nullable NSSet<GIDClaim *> *)claims
                                 completion:(nullable GIDSignInCompletion)completion {
   [self signInWithPresentingViewController:presentingViewController
                                       hint:hint
                           additionalScopes:additionalScopes
                                      nonce:nil
-                               tokenClaims:tokenClaims
+                                    claims:claims
                                 completion:completion];
 }
 
@@ -335,7 +335,7 @@ static NSString *const kConfigOpenIDRealmKey = @"GIDOpenIDRealm";
                                       hint:(nullable NSString *)hint
                           additionalScopes:(nullable NSArray<NSString *> *)additionalScopes
                                      nonce:(nullable NSString *)nonce
-                               tokenClaims:(nullable NSSet<GIDTokenClaim *> *)tokenClaims
+                                    claims:(nullable NSSet<GIDClaim *> *)claims
                                 completion:(nullable GIDSignInCompletion)completion {
   GIDSignInInternalOptions *options =
       [GIDSignInInternalOptions defaultOptionsWithConfiguration:_configuration
@@ -344,7 +344,7 @@ static NSString *const kConfigOpenIDRealmKey = @"GIDOpenIDRealm";
                                                   addScopesFlow:NO
                                                          scopes:additionalScopes
                                                           nonce:nonce
-                                                    tokenClaims:tokenClaims
+                                                         claims:claims
                                                      completion:completion];
   [self signInWithOptions:options];
 }
@@ -369,10 +369,10 @@ static NSString *const kConfigOpenIDRealmKey = @"GIDOpenIDRealm";
 
   OIDAuthorizationRequest *lastAuthorizationRequest =
       self.currentUser.authState.lastAuthorizationResponse.request;
-  NSString *lastTokenClaimsAsJSON =
-      lastAuthorizationRequest.additionalParameters[kTokenClaimsParameter];
-  if (lastTokenClaimsAsJSON) {
-    options.tokenClaimsAsJSON = lastTokenClaimsAsJSON;
+  NSString *lastClaimsAsJSON =
+      lastAuthorizationRequest.additionalParameters[kClaimsParameter];
+  if (lastClaimsAsJSON) {
+    options.claimsAsJSON = lastClaimsAsJSON;
   }
 
   NSSet<NSString *> *requestedScopes = [NSSet setWithArray:scopes];
@@ -441,40 +441,40 @@ static NSString *const kConfigOpenIDRealmKey = @"GIDOpenIDRealm";
                               hint:hint
                   additionalScopes:additionalScopes
                              nonce:nonce
-                       tokenClaims:nil
+                            claims:nil
                         completion:completion];
 }
 
 - (void)signInWithPresentingWindow:(NSWindow *)presentingWindow
-                       tokenClaims:(nullable NSSet<GIDTokenClaim *> *)tokenClaims
+                            claims:(nullable NSSet<GIDClaim *> *)claims
                         completion:(nullable GIDSignInCompletion)completion {
   [self signInWithPresentingWindow:presentingWindow
                               hint:nil
-                       tokenClaims:tokenClaims
+                            claims:claims
                         completion:completion];
 }
 
 - (void)signInWithPresentingWindow:(NSWindow *)presentingWindow
                               hint:(nullable NSString *)hint
-                       tokenClaims:(nullable NSSet<GIDTokenClaim *> *)tokenClaims
+                            claims:(nullable NSSet<GIDClaim *> *)claims
                         completion:(nullable GIDSignInCompletion)completion {
   [self signInWithPresentingWindow:presentingWindow
                               hint:hint
                   additionalScopes:@[]
-                       tokenClaims:tokenClaims
+                            claims:claims
                         completion:completion];
 }
 
 - (void)signInWithPresentingWindow:(NSWindow *)presentingWindow
                               hint:(nullable NSString *)hint
                   additionalScopes:(nullable NSArray<NSString *> *)additionalScopes
-                       tokenClaims:(nullable NSSet<GIDTokenClaim *> *)tokenClaims
+                            claims:(nullable NSSet<GIDClaim *> *)claims
                         completion:(nullable GIDSignInCompletion)completion {
   [self signInWithPresentingWindow:presentingWindow
                               hint:hint
                   additionalScopes:additionalScopes
                              nonce:nil
-                       tokenClaims:tokenClaims
+                            claims:claims
                         completion:completion];
 }
 
@@ -482,7 +482,7 @@ static NSString *const kConfigOpenIDRealmKey = @"GIDOpenIDRealm";
                               hint:(nullable NSString *)hint
                   additionalScopes:(nullable NSArray<NSString *> *)additionalScopes
                              nonce:(nullable NSString *)nonce
-                       tokenClaims:(nullable NSSet<GIDTokenClaim *> *)tokenClaims
+                            claims:(nullable NSSet<GIDClaim *> *)claims
                         completion:(nullable GIDSignInCompletion)completion {
   GIDSignInInternalOptions *options =
       [GIDSignInInternalOptions defaultOptionsWithConfiguration:_configuration
@@ -491,7 +491,7 @@ static NSString *const kConfigOpenIDRealmKey = @"GIDOpenIDRealm";
                                                   addScopesFlow:NO
                                                          scopes:additionalScopes
                                                           nonce:nonce
-                                                    tokenClaims:tokenClaims
+                                                         claims:claims
                                                      completion:completion];
   [self signInWithOptions:options];
 }
@@ -509,10 +509,10 @@ static NSString *const kConfigOpenIDRealmKey = @"GIDOpenIDRealm";
 
   OIDAuthorizationRequest *lastAuthorizationRequest =
       self.currentUser.authState.lastAuthorizationResponse.request;
-  NSString *lastTokenClaimsAsJSON =
-      lastAuthorizationRequest.additionalParameters[kTokenClaimsParameter];
-  if (lastTokenClaimsAsJSON) {
-    options.tokenClaimsAsJSON = lastTokenClaimsAsJSON;
+  NSString *lastClaimsAsJSON =
+      lastAuthorizationRequest.additionalParameters[kClaimsParameter];
+  if (lastClaimsAsJSON) {
+    options.claimsAsJSON = lastClaimsAsJSON;
   }
 
   NSSet<NSString *> *requestedScopes = [NSSet setWithArray:scopes];
@@ -660,7 +660,7 @@ static NSString *const kConfigOpenIDRealmKey = @"GIDOpenIDRealm";
   self = [super init];
   if (self) {
     _keychainStore = keychainStore;
-    _tokenClaimsInternalOptions = [[GIDTokenClaimsInternalOptions alloc] init];
+    _claimsInternalOptions = [[GIDClaimsInternalOptions alloc] init];
 
     // Get the bundle of the current executable.
     NSBundle *bundle = NSBundle.mainBundle;
@@ -755,14 +755,14 @@ static NSString *const kConfigOpenIDRealmKey = @"GIDOpenIDRealm";
       }
     }];
   } else {
-    // Only serialize tokenClaims if options.tokenClaimsAsJSON isn't already set.
-    if (!options.tokenClaimsAsJSON) {
+    // Only serialize claims if options.claimsAsJSON isn't already set.
+    if (!options.claimsAsJSON) {
       NSError *claimsError;
 
-      // If tokenClaims are invalid or JSON serialization fails, return with an error.
-      options.tokenClaimsAsJSON = [_tokenClaimsInternalOptions
-                                   validatedJSONStringForClaims:options.tokenClaims
-                                                          error:&claimsError];
+      // If claims are invalid or JSON serialization fails, return with an error.
+      options.claimsAsJSON = [_claimsInternalOptions
+                              validatedJSONStringForClaims:options.claims
+                                                     error:&claimsError];
       if (claimsError) {
         if (options.completion) {
           _currentOptions = nil;
@@ -902,8 +902,8 @@ static NSString *const kConfigOpenIDRealmKey = @"GIDOpenIDRealm";
   if (options.configuration.hostedDomain) {
     additionalParameters[kHostedDomainParameter] = options.configuration.hostedDomain;
   }
-  if (options.tokenClaimsAsJSON) {
-    additionalParameters[kTokenClaimsParameter] = options.tokenClaimsAsJSON;
+  if (options.claimsAsJSON) {
+    additionalParameters[kClaimsParameter] = options.claimsAsJSON;
   }
 
 #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST

+ 5 - 5
GoogleSignIn/Sources/GIDSignInInternalOptions.h

@@ -68,11 +68,11 @@ NS_ASSUME_NONNULL_BEGIN
 /// and to mitigate replay attacks.
 @property(nonatomic, readonly, copy, nullable) NSString *nonce;
 
-/// The tokenClaims requested by the Clients.
-@property(nonatomic, readonly, copy, nullable) NSSet<GIDTokenClaim *> *tokenClaims;
+/// The claims requested by the Clients.
+@property(nonatomic, readonly, copy, nullable) NSSet<GIDClaim *> *claims;
 
 /// The JSON token claims to be used during the flow.
-@property(nonatomic, copy, nullable) NSString *tokenClaimsAsJSON;
+@property(nonatomic, copy, nullable) NSString *claimsAsJSON;
 
 /// Creates the default options.
 #if TARGET_OS_IOS || TARGET_OS_MACCATALYST
@@ -88,7 +88,7 @@ NS_ASSUME_NONNULL_BEGIN
                                   addScopesFlow:(BOOL)addScopesFlow
                                          scopes:(nullable NSArray *)scopes
                                           nonce:(nullable NSString *)nonce
-                                    tokenClaims:(nullable NSSet *)tokenClaims
+                                         claims:(nullable NSSet *)claims
                                      completion:(nullable GIDSignInCompletion)completion;
 
 #elif TARGET_OS_OSX
@@ -104,7 +104,7 @@ NS_ASSUME_NONNULL_BEGIN
                                   addScopesFlow:(BOOL)addScopesFlow
                                          scopes:(nullable NSArray *)scopes
                                           nonce:(nullable NSString *)nonce
-                                    tokenClaims:(nullable NSSet *)tokenClaims
+                                         claims:(nullable NSSet *)claims
                                      completion:(nullable GIDSignInCompletion)completion;
 #endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
 

+ 5 - 5
GoogleSignIn/Sources/GIDSignInInternalOptions.m

@@ -32,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
                                   addScopesFlow:(BOOL)addScopesFlow
                                          scopes:(nullable NSArray *)scopes
                                           nonce:(nullable NSString *)nonce
-                                    tokenClaims:(nullable NSSet *)tokenClaims
+                                         claims:(nullable NSSet *)claims
                                      completion:(nullable GIDSignInCompletion)completion {
 #elif TARGET_OS_OSX
 + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
@@ -41,7 +41,7 @@ NS_ASSUME_NONNULL_BEGIN
                                   addScopesFlow:(BOOL)addScopesFlow
                                          scopes:(nullable NSArray *)scopes
                                           nonce:(nullable NSString *)nonce
-                                    tokenClaims:(nullable NSSet *)tokenClaims
+                                         claims:(nullable NSSet *)claims
                                      completion:(nullable GIDSignInCompletion)completion {
 #endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
   GIDSignInInternalOptions *options = [[GIDSignInInternalOptions alloc] init];
@@ -59,7 +59,7 @@ NS_ASSUME_NONNULL_BEGIN
     options->_completion = completion;
     options->_scopes = [GIDScopes scopesWithBasicProfile:scopes];
     options->_nonce = nonce;
-    options->_tokenClaims = tokenClaims;
+    options->_claims = claims;
   }
   return options;
 }
@@ -87,7 +87,7 @@ NS_ASSUME_NONNULL_BEGIN
                                                                 addScopesFlow:addScopesFlow
                                                                        scopes:@[]
                                                                         nonce:nil
-                                                                  tokenClaims:nil
+                                                                       claims:nil
                                                                    completion:completion];
   return options;
 }
@@ -124,7 +124,7 @@ NS_ASSUME_NONNULL_BEGIN
     options->_loginHint = _loginHint;
     options->_completion = _completion;
     options->_scopes = _scopes;
-    options->_tokenClaims = _tokenClaims;
+    options->_claims = _claims;
     options->_extraParams = [extraParams copy];
   }
   return options;

+ 1 - 1
GoogleSignIn/Sources/Public/GoogleSignIn/GIDTokenClaim.h → GoogleSignIn/Sources/Public/GoogleSignIn/GIDClaim.h

@@ -23,7 +23,7 @@ extern NSString *const kAuthTimeClaimName;
 /**
  * An object representing a single OIDC claim to be requested for an ID token.
  */
-@interface GIDTokenClaim : NSObject
+@interface GIDClaim : NSObject
 
 /// The name of the claim, e.g., "auth_time".
 @property (nonatomic, readonly) NSString *name;

+ 25 - 25
GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h

@@ -26,7 +26,7 @@
 @class GIDConfiguration;
 @class GIDGoogleUser;
 @class GIDSignInResult;
-@class GIDTokenClaim;
+@class GIDClaim;
 
 NS_ASSUME_NONNULL_BEGIN
 
@@ -226,7 +226,7 @@ NS_EXTENSION_UNAVAILABLE("The sign-in flow is not supported in App Extensions.")
                        NSError *_Nullable error))completion
     NS_EXTENSION_UNAVAILABLE("The sign-in flow is not supported in App Extensions.");
 
-/// Starts an interactive sign-in flow on iOS using the provided tokenClaims.
+/// Starts an interactive sign-in flow on iOS using the provided claims.
 ///
 /// The completion will be called at the end of this process.  Any saved sign-in state will be
 /// replaced by the result of this flow.  Note that this method should not be called when the app is
@@ -234,17 +234,17 @@ NS_EXTENSION_UNAVAILABLE("The sign-in flow is not supported in App Extensions.")
 /// `restorePreviousSignInWithCompletion:` method to restore a previous sign-in.
 ///
 /// @param presentingViewController The view controller used to present the authorization flow.
-/// @param tokenClaims An optional `NSSet` of tokenClaims to request.
+/// @param claims An optional `NSSet` of claims to request.
 /// @param completion The optional block that is called on completion.  This block will
 ///     be called asynchronously on the main queue.
 - (void)signInWithPresentingViewController:(UIViewController *)presentingViewController
-                               tokenClaims:(nullable NSSet<GIDTokenClaim *> *)tokenClaims
+                                    claims:(nullable NSSet<GIDClaim *> *)claims
                                 completion:
     (nullable void (^)(GIDSignInResult *_Nullable signInResult,
                        NSError *_Nullable error))completion
     NS_EXTENSION_UNAVAILABLE("The sign-in flow is not supported in App Extensions.");
 
-/// Starts an interactive sign-in flow on iOS using the provided hint and tokenClaims.
+/// Starts an interactive sign-in flow on iOS using the provided hint and claims.
 ///
 /// The completion will be called at the end of this process.  Any saved sign-in state will be
 /// replaced by the result of this flow.  Note that this method should not be called when the app is
@@ -254,19 +254,19 @@ NS_EXTENSION_UNAVAILABLE("The sign-in flow is not supported in App Extensions.")
 /// @param presentingViewController The view controller used to present the authorization flow.
 /// @param hint An optional hint for the authorization server, for example the user's ID or email
 ///     address, to be prefilled if possible.
-/// @param tokenClaims An optional `NSSet` of tokenClaims to request.
+/// @param claims An optional `NSSet` of claims to request.
 /// @param completion The optional block that is called on completion.  This block will
 ///     be called asynchronously on the main queue.
 - (void)signInWithPresentingViewController:(UIViewController *)presentingViewController
                                       hint:(nullable NSString *)hint
-                               tokenClaims:(nullable NSSet<GIDTokenClaim *> *)tokenClaims
+                                    claims:(nullable NSSet<GIDClaim *> *)claims
                                 completion:
     (nullable void (^)(GIDSignInResult *_Nullable signInResult,
                        NSError *_Nullable error))completion
     NS_EXTENSION_UNAVAILABLE("The sign-in flow is not supported in App Extensions.");
 
 /// Starts an interactive sign-in flow on iOS using the provided hint, additional scopes,
-/// and tokenClaims.
+/// and claims.
 ///
 /// The completion will be called at the end of this process.  Any saved sign-in state will be
 /// replaced by the result of this flow.  Note that this method should not be called when the app is
@@ -277,20 +277,20 @@ NS_EXTENSION_UNAVAILABLE("The sign-in flow is not supported in App Extensions.")
 /// @param hint An optional hint for the authorization server, for example the user's ID or email
 ///     address, to be prefilled if possible.
 /// @param additionalScopes An optional array of scopes to request in addition to the basic profile scopes.
-/// @param tokenClaims An optional `NSSet` of tokenClaims to request.
+/// @param claims An optional `NSSet` of claims to request.
 /// @param completion The optional block that is called on completion.  This block will
 ///     be called asynchronously on the main queue.
 - (void)signInWithPresentingViewController:(UIViewController *)presentingViewController
                                       hint:(nullable NSString *)hint
                           additionalScopes:(nullable NSArray<NSString *> *)additionalScopes
-                               tokenClaims:(nullable NSSet<GIDTokenClaim *> *)tokenClaims
+                                    claims:(nullable NSSet<GIDClaim *> *)claims
                                 completion:
     (nullable void (^)(GIDSignInResult *_Nullable signInResult,
                        NSError *_Nullable error))completion
     NS_EXTENSION_UNAVAILABLE("The sign-in flow is not supported in App Extensions.");
 
 /// Starts an interactive sign-in flow on iOS using the provided hint, additional scopes, nonce,
-/// and tokenClaims.
+/// and claims.
 ///
 /// The completion will be called at the end of this process.  Any saved sign-in state will be
 /// replaced by the result of this flow.  Note that this method should not be called when the app is
@@ -302,14 +302,14 @@ NS_EXTENSION_UNAVAILABLE("The sign-in flow is not supported in App Extensions.")
 ///     address, to be prefilled if possible.
 /// @param additionalScopes An optional array of scopes to request in addition to the basic profile scopes.
 /// @param nonce A custom nonce.
-/// @param tokenClaims An optional `NSSet` of tokenClaims to request.
+/// @param claims An optional `NSSet` of claims to request.
 /// @param completion The optional block that is called on completion.  This block will
 ///     be called asynchronously on the main queue.
 - (void)signInWithPresentingViewController:(UIViewController *)presentingViewController
                                       hint:(nullable NSString *)hint
                           additionalScopes:(nullable NSArray<NSString *> *)additionalScopes
                                      nonce:(nullable NSString *)nonce
-                               tokenClaims:(nullable NSSet<GIDTokenClaim *> *)tokenClaims
+                                    claims:(nullable NSSet<GIDClaim *> *)claims
                                 completion:
     (nullable void (^)(GIDSignInResult *_Nullable signInResult,
                        NSError *_Nullable error))completion
@@ -388,7 +388,7 @@ NS_EXTENSION_UNAVAILABLE("The sign-in flow is not supported in App Extensions.")
                         completion:(nullable void (^)(GIDSignInResult *_Nullable signInResult,
                                                       NSError *_Nullable error))completion;
 
-/// Starts an interactive sign-in flow on macOS using the provided tokenClaims.
+/// Starts an interactive sign-in flow on macOS using the provided claims.
 ///
 /// The completion will be called at the end of this process.  Any saved sign-in state will be
 /// replaced by the result of this flow.  Note that this method should not be called when the app is
@@ -396,15 +396,15 @@ NS_EXTENSION_UNAVAILABLE("The sign-in flow is not supported in App Extensions.")
 /// `restorePreviousSignInWithCompletion:` method to restore a previous sign-in.
 ///
 /// @param presentingWindow The window used to supply `presentationContextProvider` for `ASWebAuthenticationSession`.
-/// @param tokenClaims An optional `NSSet` of tokenClaims to request.
+/// @param claims An optional `NSSet` of claims to request.
 /// @param completion The optional block that is called on completion.  This block will
 ///     be called asynchronously on the main queue.
 - (void)signInWithPresentingWindow:(NSWindow *)presentingWindow
-                       tokenClaims:(nullable NSSet<GIDTokenClaim *> *)tokenClaims
+                            claims:(nullable NSSet<GIDClaim *> *)claims
                         completion:(nullable void (^)(GIDSignInResult *_Nullable signInResult,
                                                       NSError *_Nullable error))completion;
 
-/// Starts an interactive sign-in flow on macOS using the provided hint and tokenClaims.
+/// Starts an interactive sign-in flow on macOS using the provided hint and claims.
 ///
 /// The completion will be called at the end of this process.  Any saved sign-in state will be
 /// replaced by the result of this flow.  Note that this method should not be called when the app is
@@ -414,17 +414,17 @@ NS_EXTENSION_UNAVAILABLE("The sign-in flow is not supported in App Extensions.")
 /// @param presentingWindow The window used to supply `presentationContextProvider` for `ASWebAuthenticationSession`.
 /// @param hint An optional hint for the authorization server, for example the user's ID or email
 ///     address, to be prefilled if possible.
-/// @param tokenClaims An optional `NSSet` of tokenClaims to request.
+/// @param claims An optional `NSSet` of claims to request.
 /// @param completion The optional block that is called on completion.  This block will
 ///     be called asynchronously on the main queue.
 - (void)signInWithPresentingWindow:(NSWindow *)presentingWindow
                               hint:(nullable NSString *)hint
-                       tokenClaims:(nullable NSSet<GIDTokenClaim *> *)tokenClaims
+                            claims:(nullable NSSet<GIDClaim *> *)claims
                         completion:(nullable void (^)(GIDSignInResult *_Nullable signInResult,
                                                       NSError *_Nullable error))completion;
 
 /// Starts an interactive sign-in flow on macOS using the provided hint, additional scopes,
-/// and tokenClaims.
+/// and claims.
 ///
 /// The completion will be called at the end of this process.  Any saved sign-in state will be
 /// replaced by the result of this flow.  Note that this method should not be called when the app is
@@ -435,18 +435,18 @@ NS_EXTENSION_UNAVAILABLE("The sign-in flow is not supported in App Extensions.")
 /// @param hint An optional hint for the authorization server, for example the user's ID or email
 ///     address, to be prefilled if possible.
 /// @param additionalScopes An optional array of scopes to request in addition to the basic profile scopes.
-/// @param tokenClaims An optional `NSSet` of tokenClaims to request.
+/// @param claims An optional `NSSet` of claims to request.
 /// @param completion The optional block that is called on completion.  This block will
 ///     be called asynchronously on the main queue.
 - (void)signInWithPresentingWindow:(NSWindow *)presentingWindow
                               hint:(nullable NSString *)hint
                   additionalScopes:(nullable NSArray<NSString *> *)additionalScopes
-                       tokenClaims:(nullable NSSet<GIDTokenClaim *> *)tokenClaims
+                            claims:(nullable NSSet<GIDClaim *> *)claims
                         completion:(nullable void (^)(GIDSignInResult *_Nullable signInResult,
                                                       NSError *_Nullable error))completion;
 
 /// Starts an interactive sign-in flow on macOS using the provided hint, additional scopes, nonce,
-/// and tokenClaims.
+/// and claims.
 ///
 /// The completion will be called at the end of this process.  Any saved sign-in state will be
 /// replaced by the result of this flow.  Note that this method should not be called when the app is
@@ -458,14 +458,14 @@ NS_EXTENSION_UNAVAILABLE("The sign-in flow is not supported in App Extensions.")
 ///     address, to be prefilled if possible.
 /// @param additionalScopes An optional array of scopes to request in addition to the basic profile scopes.
 /// @param nonce A custom nonce.
-/// @param tokenClaims An optional `NSSet` of tokenClaims to request.
+/// @param claims An optional `NSSet` of claims to request.
 /// @param completion The optional block that is called on completion.  This block will
 ///     be called asynchronously on the main queue.
 - (void)signInWithPresentingWindow:(NSWindow *)presentingWindow
                               hint:(nullable NSString *)hint
                   additionalScopes:(nullable NSArray<NSString *> *)additionalScopes
                              nonce:(nullable NSString *)nonce
-                       tokenClaims:(nullable NSSet<GIDTokenClaim *> *)tokenClaims
+                            claims:(nullable NSSet<GIDClaim *> *)claims
                         completion:(nullable void (^)(GIDSignInResult *_Nullable signInResult,
                                                       NSError *_Nullable error))completion;
 

+ 1 - 1
GoogleSignIn/Sources/Public/GoogleSignIn/GoogleSignIn.h

@@ -24,7 +24,7 @@
 #import "GIDSignIn.h"
 #import "GIDToken.h"
 #import "GIDSignInResult.h"
-#import "GIDTokenClaim.h"
+#import "GIDClaim.h"
 #if TARGET_OS_IOS || TARGET_OS_MACCATALYST
 #import "GIDSignInButton.h"
 #endif

+ 9 - 9
GoogleSignIn/Tests/Unit/GIDTokenClaimTest.m → GoogleSignIn/Tests/Unit/GIDClaimTest.m

@@ -14,35 +14,35 @@
 
 
 #import <XCTest/XCTest.h>
-#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDTokenClaim.h"
+#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDClaim.h"
 
-@interface GIDTokenClaimTest : XCTestCase
+@interface GIDClaimTest : XCTestCase
 @end
 
-@implementation GIDTokenClaimTest
+@implementation GIDClaimTest
 
 - (void)testAuthTimeClaim_PropertiesAreCorrect {
-  GIDTokenClaim *claim = [GIDTokenClaim authTimeClaim];
+  GIDClaim *claim = [GIDClaim authTimeClaim];
   XCTAssertEqualObjects(claim.name, kAuthTimeClaimName);
   XCTAssertFalse(claim.isEssential);
 }
 
 - (void)testEssentialAuthTimeClaim_PropertiesAreCorrect {
-  GIDTokenClaim *claim = [GIDTokenClaim essentialAuthTimeClaim];
+  GIDClaim *claim = [GIDClaim essentialAuthTimeClaim];
   XCTAssertEqualObjects(claim.name, kAuthTimeClaimName);
   XCTAssertTrue(claim.isEssential);
 }
 
 - (void)testEquality_WithEqualClaims {
-  GIDTokenClaim *claim1 = [GIDTokenClaim authTimeClaim];
-  GIDTokenClaim *claim2 = [GIDTokenClaim authTimeClaim];
+  GIDClaim *claim1 = [GIDClaim authTimeClaim];
+  GIDClaim *claim2 = [GIDClaim authTimeClaim];
   XCTAssertEqualObjects(claim1, claim2);
   XCTAssertEqual(claim1.hash, claim2.hash);
 }
 
 - (void)testEquality_WithUnequalClaims {
-  GIDTokenClaim *claim1 = [GIDTokenClaim authTimeClaim];
-  GIDTokenClaim *claim2 = [GIDTokenClaim essentialAuthTimeClaim];
+  GIDClaim *claim1 = [GIDClaim authTimeClaim];
+  GIDClaim *claim2 = [GIDClaim essentialAuthTimeClaim];
   XCTAssertNotEqualObjects(claim1, claim2);
 }
 

+ 18 - 18
GoogleSignIn/Tests/Unit/GIDTokenClaimsInternalOptionsTest.m → GoogleSignIn/Tests/Unit/GIDClaimsInternalOptionsTest.m

@@ -16,59 +16,59 @@
 
 #import "GoogleSignIn/Sources/GIDJSONSerializer/Fake/GIDFakeJSONSerializerImpl.h"
 #import "GoogleSignIn/Sources/GIDJSONSerializer/Implementation/GIDJSONSerializerImpl.h"
-#import "GoogleSignIn/Sources/GIDTokenClaimsInternalOptions.h"
+#import "GoogleSignIn/Sources/GIDClaimsInternalOptions.h"
 #import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h"
-#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDTokenClaim.h"
+#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDClaim.h"
 
 static NSString *const kEssentialAuthTimeExpectedJSON = @"{\"id_token\":{\"auth_time\":{\"essential\":true}}}";
 static NSString *const kNonEssentialAuthTimeExpectedJSON = @"{\"id_token\":{\"auth_time\":{\"essential\":false}}}";
 
-@interface GIDTokenClaimsInternalOptionsTest : XCTestCase
+@interface GIDClaimsInternalOptionsTest : XCTestCase
 
 @property(nonatomic) GIDFakeJSONSerializerImpl *jsonSerializerFake;
-@property(nonatomic) GIDTokenClaimsInternalOptions *tokenClaimsInternalOptions;
+@property(nonatomic) GIDClaimsInternalOptions *claimsInternalOptions;
 
 @end
 
-@implementation GIDTokenClaimsInternalOptionsTest
+@implementation GIDClaimsInternalOptionsTest
 
 - (void)setUp {
   [super setUp];
   _jsonSerializerFake = [[GIDFakeJSONSerializerImpl alloc] init];
-  _tokenClaimsInternalOptions = [[GIDTokenClaimsInternalOptions alloc] initWithJSONSerializer:_jsonSerializerFake];
+  _claimsInternalOptions = [[GIDClaimsInternalOptions alloc] initWithJSONSerializer:_jsonSerializerFake];
 }
 
 - (void)tearDown {
   _jsonSerializerFake = nil;
-  _tokenClaimsInternalOptions = nil;
+  _claimsInternalOptions = nil;
   [super tearDown];
 }
 
 #pragma mark - Input Validation Tests
 
 - (void)testValidatedJSONStringForClaims_WithNilInput_ShouldReturnNil {
-  XCTAssertNil([_tokenClaimsInternalOptions validatedJSONStringForClaims:nil error:nil]);
+  XCTAssertNil([_claimsInternalOptions validatedJSONStringForClaims:nil error:nil]);
 }
 
 - (void)testValidatedJSONStringForClaims_WithEmptyInput_ShouldReturnNil {
-  XCTAssertNil([_tokenClaimsInternalOptions validatedJSONStringForClaims:[NSSet set] error:nil]);
+  XCTAssertNil([_claimsInternalOptions validatedJSONStringForClaims:[NSSet set] error:nil]);
 }
 
 #pragma mark - Correct Formatting Tests
 
 - (void)testValidatedJSONStringForClaims_WithNonEssentialClaim_IsCorrectlyFormatted {
-  NSSet *claims = [NSSet setWithObject:[GIDTokenClaim authTimeClaim]];
+  NSSet *claims = [NSSet setWithObject:[GIDClaim authTimeClaim]];
   NSError *error;
-  NSString *result = [_tokenClaimsInternalOptions validatedJSONStringForClaims:claims error:&error];
+  NSString *result = [_claimsInternalOptions validatedJSONStringForClaims:claims error:&error];
 
   XCTAssertNil(error);
   XCTAssertEqualObjects(result, kNonEssentialAuthTimeExpectedJSON);
 }
 
 - (void)testValidatedJSONStringForClaims_WithEssentialClaim_IsCorrectlyFormatted {
-  NSSet *claims = [NSSet setWithObject:[GIDTokenClaim essentialAuthTimeClaim]];
+  NSSet *claims = [NSSet setWithObject:[GIDClaim essentialAuthTimeClaim]];
   NSError *error;
-  NSString *result = [_tokenClaimsInternalOptions validatedJSONStringForClaims:claims error:&error];
+  NSString *result = [_claimsInternalOptions validatedJSONStringForClaims:claims error:&error];
 
   XCTAssertNil(error);
   XCTAssertEqualObjects(result, kEssentialAuthTimeExpectedJSON);
@@ -77,11 +77,11 @@ static NSString *const kNonEssentialAuthTimeExpectedJSON = @"{\"id_token\":{\"au
 #pragma mark - Client Error Handling Tests
 
 - (void)testValidatedJSONStringForClaims_WithConflictingClaims_ReturnsNilAndPopulatesError {
-  NSSet *claims = [NSSet setWithObjects:[GIDTokenClaim authTimeClaim],
-                                        [GIDTokenClaim essentialAuthTimeClaim],
+  NSSet *claims = [NSSet setWithObjects:[GIDClaim authTimeClaim],
+                                        [GIDClaim essentialAuthTimeClaim],
                                         nil];
   NSError *error;
-  NSString *result = [_tokenClaimsInternalOptions validatedJSONStringForClaims:claims error:&error];
+  NSString *result = [_claimsInternalOptions validatedJSONStringForClaims:claims error:&error];
 
   XCTAssertNil(result, @"Method should return nil for conflicting claims.");
   XCTAssertNotNil(error, @"An error object should be populated.");
@@ -91,7 +91,7 @@ static NSString *const kNonEssentialAuthTimeExpectedJSON = @"{\"id_token\":{\"au
 }
 
 - (void)testValidatedJSONStringForClaims_WhenSerializationFails_ReturnsNilAndError {
-  NSSet *claims = [NSSet setWithObject:[GIDTokenClaim authTimeClaim]];
+  NSSet *claims = [NSSet setWithObject:[GIDClaim authTimeClaim]];
   NSError *expectedJSONError = [NSError errorWithDomain:kGIDSignInErrorDomain
                                                    code:kGIDSignInErrorCodeJSONSerializationFailure
                                                userInfo:@{
@@ -99,7 +99,7 @@ static NSString *const kNonEssentialAuthTimeExpectedJSON = @"{\"id_token\":{\"au
                                                }];
   _jsonSerializerFake.serializationError = expectedJSONError;
   NSError *actualError;
-  NSString *result = [_tokenClaimsInternalOptions validatedJSONStringForClaims:claims
+  NSString *result = [_claimsInternalOptions validatedJSONStringForClaims:claims
                                                                          error:&actualError];
 
   XCTAssertNil(result, @"The result should be nil when JSON serialization fails.");

+ 5 - 5
GoogleSignIn/Tests/Unit/GIDSignInInternalOptionsTest.m

@@ -17,7 +17,7 @@
 #import "GoogleSignIn/Sources/GIDSignInInternalOptions.h"
 
 #import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDConfiguration.h"
-#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDTokenClaim.h"
+#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDClaim.h"
 
 #ifdef SWIFT_PACKAGE
 @import OCMock;
@@ -74,7 +74,7 @@
   NSString *loginHint = @"login_hint";
   NSArray<NSString *> *scopes = @[@"scope1", @"scope2"];
   NSString *nonce = @"test_nonce";
-  NSSet<GIDTokenClaim *> *tokenClaims = [NSSet setWithObject:[GIDTokenClaim authTimeClaim]];
+  NSSet<GIDClaim *> *claims = [NSSet setWithObject:[GIDClaim authTimeClaim]];
   NSArray<NSString *> *expectedScopes = @[@"scope1", @"scope2", @"email", @"profile"];
 
   GIDSignInCompletion completion = ^(GIDSignInResult *_Nullable signInResult,
@@ -90,7 +90,7 @@
                                                   addScopesFlow:NO
                                                          scopes:scopes
                                                           nonce:nonce
-                                                    tokenClaims:tokenClaims
+                                                         claims:claims
                                                      completion:completion];
   XCTAssertTrue(options.interactive);
   XCTAssertFalse(options.continuation);
@@ -100,8 +100,8 @@
   // Convert arrays to sets for comparison to make the test order-independent.
   XCTAssertEqualObjects([NSSet setWithArray:options.scopes], [NSSet setWithArray:expectedScopes]);
   XCTAssertEqualObjects(options.nonce, nonce);
-  XCTAssertEqualObjects(options.tokenClaims, tokenClaims);
-  XCTAssertNil(options.tokenClaimsAsJSON);
+  XCTAssertEqualObjects(options.claims, claims);
+  XCTAssertNil(options.claimsAsJSON);
 
   OCMVerifyAll(configuration);
 #if TARGET_OS_IOS || TARGET_OS_MACCATALYST

+ 69 - 69
GoogleSignIn/Tests/Unit/GIDSignInTest.m

@@ -32,7 +32,7 @@
 #import "GoogleSignIn/Sources/GIDGoogleUser_Private.h"
 #import "GoogleSignIn/Sources/GIDSignIn_Private.h"
 #import "GoogleSignIn/Sources/GIDSignInPreferences.h"
-#import "GoogleSignIn/Sources/GIDTokenClaimsInternalOptions.h"
+#import "GoogleSignIn/Sources/GIDClaimsInternalOptions.h"
 
 #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
 #import <AppCheckCore/GACAppCheckToken.h>
@@ -644,7 +644,7 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                           authError:nil
                          tokenError:nil
             emmPasscodeInfoRequired:NO
-          tokenClaimsAsJSONRequired:NO
+               claimsAsJSONRequired:NO
                       keychainError:NO
                      restoredSignIn:NO
                      oldAccessToken:NO
@@ -662,7 +662,7 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                           authError:nil
                          tokenError:nil
             emmPasscodeInfoRequired:NO
-          tokenClaimsAsJSONRequired:NO
+               claimsAsJSONRequired:NO
                       keychainError:NO
                      restoredSignIn:YES
                      oldAccessToken:NO
@@ -680,7 +680,7 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                           authError:nil
                          tokenError:nil
             emmPasscodeInfoRequired:NO
-          tokenClaimsAsJSONRequired:NO
+               claimsAsJSONRequired:NO
                       keychainError:NO
                      restoredSignIn:YES
                      oldAccessToken:YES
@@ -700,16 +700,16 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                           authError:nil
                          tokenError:nil
             emmPasscodeInfoRequired:NO
-          tokenClaimsAsJSONRequired:NO
+               claimsAsJSONRequired:NO
                       keychainError:NO
-                   tokenClaimsError:NO
+                        claimsError:NO
                      restoredSignIn:NO
                      oldAccessToken:NO
                         modalCancel:NO
                 useAdditionalScopes:YES
                    additionalScopes:nil
                         manualNonce:nil
-                        tokenClaims:nil];
+                             claims:nil];
 
   expectedScopeString = [@[ @"email", @"profile" ] componentsJoinedByString:@" "];
   XCTAssertEqualObjects(_savedAuthorizationRequest.scope, expectedScopeString);
@@ -718,16 +718,16 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                           authError:nil
                          tokenError:nil
             emmPasscodeInfoRequired:NO
-          tokenClaimsAsJSONRequired:NO
+               claimsAsJSONRequired:NO
                       keychainError:NO
-                   tokenClaimsError:NO
+                        claimsError:NO
                      restoredSignIn:NO
                      oldAccessToken:NO
                         modalCancel:NO
                 useAdditionalScopes:YES
                    additionalScopes:@[ kScope ]
                         manualNonce:nil
-                        tokenClaims:nil];
+                             claims:nil];
 
   expectedScopeString = [@[ kScope, @"email", @"profile" ] componentsJoinedByString:@" "];
   XCTAssertEqualObjects(_savedAuthorizationRequest.scope, expectedScopeString);
@@ -736,24 +736,24 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                           authError:nil
                          tokenError:nil
             emmPasscodeInfoRequired:NO
-          tokenClaimsAsJSONRequired:NO
+               claimsAsJSONRequired:NO
                       keychainError:NO
-                   tokenClaimsError:NO
+                        claimsError:NO
                      restoredSignIn:NO
                      oldAccessToken:NO
                         modalCancel:NO
                 useAdditionalScopes:YES
                    additionalScopes:@[ kScope, kScope2 ]
                         manualNonce:nil
-                        tokenClaims:nil];
+                             claims:nil];
 
   expectedScopeString = [@[ kScope, kScope2, @"email", @"profile" ] componentsJoinedByString:@" "];
   XCTAssertEqualObjects(_savedAuthorizationRequest.scope, expectedScopeString);
 }
 
-- (void)testOAuthLogin_WithTokenClaims_FormatsParametersCorrectly {
-  GIDTokenClaim *authTimeClaim = [GIDTokenClaim authTimeClaim];
-  GIDTokenClaim *essentialAuthTimeClaim = [GIDTokenClaim essentialAuthTimeClaim];
+- (void)testOAuthLogin_WithClaims_FormatsParametersCorrectly {
+  GIDClaim *authTimeClaim = [GIDClaim authTimeClaim];
+  GIDClaim *essentialAuthTimeClaim = [GIDClaim essentialAuthTimeClaim];
 
   OCMStub([_keychainStore saveAuthSession:OCMOCK_ANY error:OCMArg.anyObjectRef]
           ).andDo(^(NSInvocation *invocation){
@@ -764,16 +764,16 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                           authError:nil
                          tokenError:nil
             emmPasscodeInfoRequired:NO
-          tokenClaimsAsJSONRequired:NO
+               claimsAsJSONRequired:NO
                       keychainError:NO
-                   tokenClaimsError:NO
+                        claimsError:NO
                      restoredSignIn:NO
                      oldAccessToken:NO
                         modalCancel:NO
                 useAdditionalScopes:NO
                    additionalScopes:nil
                         manualNonce:nil
-                        tokenClaims:[NSSet setWithObject:essentialAuthTimeClaim]];
+                             claims:[NSSet setWithObject:essentialAuthTimeClaim]];
 
   XCTAssertEqualObjects(_savedAuthorizationRequest.additionalParameters[@"claims"],
                         kEssentialAuthTimeClaimsJsonString,
@@ -783,24 +783,24 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                           authError:nil
                          tokenError:nil
             emmPasscodeInfoRequired:NO
-          tokenClaimsAsJSONRequired:NO
+               claimsAsJSONRequired:NO
                       keychainError:NO
-                   tokenClaimsError:NO
+                        claimsError:NO
                      restoredSignIn:NO
                      oldAccessToken:NO
                         modalCancel:NO
                 useAdditionalScopes:NO
                    additionalScopes:nil
                         manualNonce:nil
-                        tokenClaims:[NSSet setWithObject:authTimeClaim]];
+                             claims:[NSSet setWithObject:authTimeClaim]];
 
   XCTAssertEqualObjects(_savedAuthorizationRequest.additionalParameters[@"claims"],
                         kNonEssentialAuthTimeClaimsJsonString,
                         @"Claims JSON should be correctly formatted");
 }
 
-- (void)testOAuthLogin_WithTokenClaims_ReturnsIdTokenWithCorrectClaims {
-  GIDTokenClaim *authTimeClaim = [GIDTokenClaim authTimeClaim];
+- (void)testOAuthLogin_WithClaims_ReturnsIdTokenWithCorrectClaims {
+  GIDClaim *authTimeClaim = [GIDClaim authTimeClaim];
 
   OCMStub([_keychainStore saveAuthSession:OCMOCK_ANY error:OCMArg.anyObjectRef]
           ).andDo(^(NSInvocation *invocation){
@@ -811,16 +811,16 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                           authError:nil
                          tokenError:nil
             emmPasscodeInfoRequired:NO
-          tokenClaimsAsJSONRequired:NO
+               claimsAsJSONRequired:NO
                       keychainError:NO
-                   tokenClaimsError:NO
+                        claimsError:NO
                      restoredSignIn:NO
                      oldAccessToken:NO
                         modalCancel:NO
                 useAdditionalScopes:NO
                    additionalScopes:nil
                         manualNonce:nil
-                        tokenClaims:[NSSet setWithObject:authTimeClaim]];
+                             claims:[NSSet setWithObject:authTimeClaim]];
 
   XCTAssertNotNil(_signIn.currentUser, @"The currentUser should not be nil after a successful sign-in.");
   NSString *idTokenString = _signIn.currentUser.idToken.tokenString;
@@ -847,7 +847,7 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                           authError:nil
                          tokenError:nil
             emmPasscodeInfoRequired:NO
-          tokenClaimsAsJSONRequired:NO
+               claimsAsJSONRequired:NO
                       keychainError:NO
                      restoredSignIn:YES
                      oldAccessToken:NO
@@ -872,7 +872,7 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                           authError:nil
                          tokenError:nil
             emmPasscodeInfoRequired:NO
-          tokenClaimsAsJSONRequired:NO
+               claimsAsJSONRequired:NO
                       keychainError:NO
                      restoredSignIn:NO
                      oldAccessToken:NO
@@ -901,7 +901,7 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
 }
 
 - (void)testAddScopes_WithPreviouslyRequestedClaims {
-  GIDTokenClaim *authTimeClaim = [GIDTokenClaim authTimeClaim];
+  GIDClaim *authTimeClaim = [GIDClaim authTimeClaim];
   // Restore the previous sign-in account. This is the preparation for adding scopes.
   OCMStub(
     [_keychainStore saveAuthSession:OCMOCK_ANY error:OCMArg.anyObjectRef]
@@ -912,16 +912,16 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                           authError:nil
                          tokenError:nil
             emmPasscodeInfoRequired:NO
-          tokenClaimsAsJSONRequired:NO
+               claimsAsJSONRequired:NO
                       keychainError:NO
-                   tokenClaimsError:NO
+                        claimsError:NO
                      restoredSignIn:NO
                      oldAccessToken:NO
                         modalCancel:NO
                 useAdditionalScopes:NO
                    additionalScopes:nil
                         manualNonce:nil
-                        tokenClaims:[NSSet setWithObject:authTimeClaim]];
+                        claims:[NSSet setWithObject:authTimeClaim]];
 
   XCTAssertNotNil(_signIn.currentUser);
 
@@ -941,7 +941,7 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                           authError:nil
                          tokenError:nil
             emmPasscodeInfoRequired:NO
-          tokenClaimsAsJSONRequired:YES
+               claimsAsJSONRequired:YES
                       keychainError:NO
                      restoredSignIn:NO
                      oldAccessToken:NO
@@ -986,7 +986,7 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                           authError:nil
                          tokenError:nil
             emmPasscodeInfoRequired:NO
-          tokenClaimsAsJSONRequired:NO
+               claimsAsJSONRequired:NO
                       keychainError:NO
                      restoredSignIn:NO
                      oldAccessToken:NO
@@ -1014,16 +1014,16 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                           authError:nil
                          tokenError:nil
             emmPasscodeInfoRequired:NO
-          tokenClaimsAsJSONRequired:NO
+               claimsAsJSONRequired:NO
                       keychainError:NO
-                   tokenClaimsError:NO
+                        claimsError:NO
                      restoredSignIn:NO
                      oldAccessToken:NO
                         modalCancel:NO
                 useAdditionalScopes:NO
                    additionalScopes:@[]
                         manualNonce:manualNonce
-                        tokenClaims:nil];
+                             claims:nil];
 
   XCTAssertEqualObjects(_savedAuthorizationRequest.nonce,
                         manualNonce,
@@ -1043,7 +1043,7 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                           authError:nil
                          tokenError:nil
             emmPasscodeInfoRequired:NO
-          tokenClaimsAsJSONRequired:NO
+               claimsAsJSONRequired:NO
                       keychainError:NO
                      restoredSignIn:NO
                      oldAccessToken:NO
@@ -1069,7 +1069,7 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                           authError:nil
                          tokenError:nil
             emmPasscodeInfoRequired:NO
-          tokenClaimsAsJSONRequired:NO
+               claimsAsJSONRequired:NO
                       keychainError:NO
                      restoredSignIn:NO
                      oldAccessToken:NO
@@ -1084,7 +1084,7 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                           authError:@"access_denied"
                          tokenError:nil
             emmPasscodeInfoRequired:NO
-          tokenClaimsAsJSONRequired:NO
+               claimsAsJSONRequired:NO
                       keychainError:NO
                      restoredSignIn:NO
                      oldAccessToken:NO
@@ -1099,7 +1099,7 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                           authError:nil
                          tokenError:nil
             emmPasscodeInfoRequired:NO
-          tokenClaimsAsJSONRequired:NO
+               claimsAsJSONRequired:NO
                       keychainError:NO
                      restoredSignIn:NO
                      oldAccessToken:NO
@@ -1124,7 +1124,7 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                           authError:nil
                          tokenError:nil
             emmPasscodeInfoRequired:NO
-          tokenClaimsAsJSONRequired:NO
+               claimsAsJSONRequired:NO
                       keychainError:YES
                      restoredSignIn:NO
                      oldAccessToken:NO
@@ -1136,25 +1136,25 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
   XCTAssertEqual(_authError.code, kGIDSignInErrorCodeKeychain);
 }
 
-- (void)testOAuthLogin_TokenClaims_FailsWithError {
-  GIDTokenClaim *authTimeClaim = [GIDTokenClaim authTimeClaim];
-  GIDTokenClaim *essentialAuthTimeClaim = [GIDTokenClaim essentialAuthTimeClaim];
+- (void)testOAuthLogin_Claims_FailsWithError {
+  GIDClaim *authTimeClaim = [GIDClaim authTimeClaim];
+  GIDClaim *essentialAuthTimeClaim = [GIDClaim essentialAuthTimeClaim];
   NSSet *conflictingClaims = [NSSet setWithObjects:authTimeClaim, essentialAuthTimeClaim, nil];
 
   [self OAuthLoginWithAddScopesFlow:NO
                           authError:nil
                          tokenError:nil
             emmPasscodeInfoRequired:NO
-          tokenClaimsAsJSONRequired:NO
+               claimsAsJSONRequired:NO
                       keychainError:NO
-                   tokenClaimsError:YES
+                        claimsError:YES
                      restoredSignIn:NO
                      oldAccessToken:NO
                         modalCancel:NO
                 useAdditionalScopes:NO
                    additionalScopes:nil
                         manualNonce:nil
-                        tokenClaims:conflictingClaims];
+                             claims:conflictingClaims];
 
   // Wait for the completion handler to be called
   [self waitForExpectationsWithTimeout:1.0 handler:nil];
@@ -1163,7 +1163,7 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                  @"The error code should be for ambiguous claims.");
   XCTAssertEqualObjects(_authError.domain, kGIDSignInErrorDomain,
                         @"The error domain should be the GIDSignIn error domain.");
-  XCTAssertEqualObjects(_authError.localizedDescription, kGIDTokenClaimErrorDescription,
+  XCTAssertEqualObjects(_authError.localizedDescription, kGIDClaimErrorDescription,
                         @"The error description should clearly explain the ambiguity.");
 }
 
@@ -1183,7 +1183,7 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                           authError:nil
                          tokenError:nil
             emmPasscodeInfoRequired:NO
-          tokenClaimsAsJSONRequired:NO
+               claimsAsJSONRequired:NO
                       keychainError:NO
                      restoredSignIn:YES
                      oldAccessToken:NO
@@ -1430,7 +1430,7 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                           authError:nil
                          tokenError:nil
             emmPasscodeInfoRequired:NO
-          tokenClaimsAsJSONRequired:NO
+               claimsAsJSONRequired:NO
                       keychainError:NO
                      restoredSignIn:NO
                      oldAccessToken:NO
@@ -1482,7 +1482,7 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                           authError:nil
                          tokenError:nil
             emmPasscodeInfoRequired:YES
-          tokenClaimsAsJSONRequired:NO
+               claimsAsJSONRequired:NO
                       keychainError:NO
                      restoredSignIn:NO
                      oldAccessToken:NO
@@ -1514,7 +1514,7 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                           authError:callbackParams[@"error"]
                          tokenError:nil
             emmPasscodeInfoRequired:NO
-          tokenClaimsAsJSONRequired:NO
+               claimsAsJSONRequired:NO
                       keychainError:NO
                      restoredSignIn:NO
                      oldAccessToken:NO
@@ -1552,7 +1552,7 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                           authError:nil
                          tokenError:emmError
             emmPasscodeInfoRequired:NO
-          tokenClaimsAsJSONRequired:NO
+               claimsAsJSONRequired:NO
                       keychainError:NO
                      restoredSignIn:NO
                      oldAccessToken:NO
@@ -1637,7 +1637,7 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                           authError:(NSString *)authError
                          tokenError:(NSError *)tokenError
             emmPasscodeInfoRequired:(BOOL)emmPasscodeInfoRequired
-          tokenClaimsAsJSONRequired:(BOOL)tokenClaimsAsJSONRequired
+               claimsAsJSONRequired:(BOOL)claimsAsJSONRequired
                       keychainError:(BOOL)keychainError
                      restoredSignIn:(BOOL)restoredSignIn
                      oldAccessToken:(BOOL)oldAccessToken
@@ -1646,16 +1646,16 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                           authError:authError
                          tokenError:tokenError
             emmPasscodeInfoRequired:emmPasscodeInfoRequired
-          tokenClaimsAsJSONRequired:tokenClaimsAsJSONRequired
+               claimsAsJSONRequired:claimsAsJSONRequired
                       keychainError:keychainError
-                   tokenClaimsError:NO
+                        claimsError:NO
                      restoredSignIn:restoredSignIn
                      oldAccessToken:oldAccessToken
                         modalCancel:modalCancel
                 useAdditionalScopes:NO
                    additionalScopes:nil
                         manualNonce:nil
-                        tokenClaims:nil];
+                             claims:nil];
 }
 
 // The authorization flow with parameters to control which branches to take.
@@ -1663,16 +1663,16 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                           authError:(NSString *)authError
                          tokenError:(NSError *)tokenError
             emmPasscodeInfoRequired:(BOOL)emmPasscodeInfoRequired
-          tokenClaimsAsJSONRequired:(BOOL)tokenClaimsAsJSONRequired
+               claimsAsJSONRequired:(BOOL)claimsAsJSONRequired
                       keychainError:(BOOL)keychainError
-                   tokenClaimsError:(BOOL)tokenClaimsError
+                        claimsError:(BOOL)claimsError
                      restoredSignIn:(BOOL)restoredSignIn
                      oldAccessToken:(BOOL)oldAccessToken
                         modalCancel:(BOOL)modalCancel
                 useAdditionalScopes:(BOOL)useAdditionalScopes
                    additionalScopes:(NSArray *)additionalScopes
                         manualNonce:(NSString *)nonce
-                        tokenClaims:(NSSet *)tokenClaims {
+                             claims:(NSSet *)claims {
   if (restoredSignIn) {
     // clearAndAuthenticateWithOptions
     [[[_authorization expect] andReturn:_authState] authState];
@@ -1682,13 +1682,13 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
 
   NSDictionary<NSString *, NSString *> *additionalParameters =
       [self additionalParametersWithEMMPasscodeInfoRequired:emmPasscodeInfoRequired
-                                  tokenClaimsAsJSONRequired:tokenClaimsAsJSONRequired];
+                                       claimsAsJSONRequired:claimsAsJSONRequired];
   OIDAuthorizationResponse *authResponse =
       [OIDAuthorizationResponse testInstanceWithAdditionalParameters:additionalParameters
                                                                nonce:nonce
                                                          errorString:authError];
 
-  NSString *idToken = tokenClaims ? [OIDTokenResponse fatIDTokenWithAuthTime] : [OIDTokenResponse fatIDToken];
+  NSString *idToken = claims ? [OIDTokenResponse fatIDTokenWithAuthTime] : [OIDTokenResponse fatIDToken];
   OIDTokenResponse *tokenResponse =
       [OIDTokenResponse testInstanceWithIDToken:idToken
                                     accessToken:restoredSignIn ? kAccessToken : nil
@@ -1696,7 +1696,7 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                                    refreshToken:kRefreshToken
                                    tokenRequest:nil];
 
-  if (tokenClaims) {
+  if (claims) {
     // Creating this stub to use `currentUser.idToken`.
     id mockIDToken = OCMClassMock([GIDToken class]);
     OCMStub([mockIDToken tokenString]).andReturn(tokenResponse.idToken);
@@ -1772,14 +1772,14 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
                                        hint:_hint
                            additionalScopes:nil
                                       nonce:nonce
-                                tokenClaims:tokenClaims
+                                     claims:claims
                                  completion:completion];
       }
     }
 
     // When token claims are invalid, sign-in fails skipping the entire authorization flow.
     // Thus, no need to verify `_authorization` or `_authState` as they won't be generated.
-    if (tokenClaimsError) {
+    if (claimsError) {
       return;
     }
 
@@ -1950,14 +1950,14 @@ static NSString *const kNonEssentialAuthTimeClaimsJsonString =
 
 - (NSDictionary<NSString *, NSString *> *)
     additionalParametersWithEMMPasscodeInfoRequired:(BOOL)emmPasscodeInfoRequired
-                          tokenClaimsAsJSONRequired:(BOOL)tokenClaimsAsJSONRequired {
+                               claimsAsJSONRequired:(BOOL)claimsAsJSONRequired {
   NSMutableDictionary<NSString *, NSString *> *additionalParameters =
       [NSMutableDictionary dictionary];
 
   if (emmPasscodeInfoRequired) {
     additionalParameters[@"emm_passcode_info_required"] = @"1";
   }
-  if (tokenClaimsAsJSONRequired) {
+  if (claimsAsJSONRequired) {
     additionalParameters[@"claims"] = kNonEssentialAuthTimeClaimsJsonString;
   }
 

+ 3 - 3
Samples/Swift/DaysUntilBirthday/Shared/Services/GoogleSignInAuthenticator.swift

@@ -20,7 +20,7 @@ import GoogleSignIn
 /// An observable class for authenticating via Google.
 final class GoogleSignInAuthenticator: ObservableObject {
   private var authViewModel: AuthenticationViewModel
-  private var tokenClaims: Set<GIDTokenClaim> = Set([GIDTokenClaim.authTime()])
+  private var claims: Set<GIDClaim> = Set([GIDClaim.authTime()])
 
   /// Creates an instance of this authenticator.
   /// - parameter authViewModel: The view model this authenticator will set logged in status on.
@@ -43,7 +43,7 @@ final class GoogleSignInAuthenticator: ObservableObject {
       hint: nil,
       additionalScopes: nil,
       nonce: manualNonce,
-      tokenClaims: tokenClaims
+      claims: claims
     ) { signInResult, error in
       guard let signInResult = signInResult else {
         print("Error! \(String(describing: error))")
@@ -70,7 +70,7 @@ final class GoogleSignInAuthenticator: ObservableObject {
 
     GIDSignIn.sharedInstance.signIn(
       withPresenting: presentingWindow,
-      tokenClaims: tokenClaims
+      claims: claims
     ) { signInResult, error in
       guard let signInResult = signInResult else {
         print("Error! \(String(describing: error))")