From 93c5b54dceaca3e884d03dc13cb95f7a6b0ec650 Mon Sep 17 00:00:00 2001 From: Akshat Gandhi <54901287+AkshatG6@users.noreply.github.com> Date: Fri, 26 Sep 2025 11:50:42 -0700 Subject: [PATCH 1/2] Renamed to throughout the code. --- .../Sources/{GIDTokenClaim.m => GIDClaim.m} | 10 +- ...alOptions.h => GIDClaimsInternalOptions.h} | 18 +-- ...alOptions.m => GIDClaimsInternalOptions.m} | 34 ++--- GoogleSignIn/Sources/GIDSignIn.m | 76 +++++----- .../Sources/GIDSignInInternalOptions.h | 10 +- .../Sources/GIDSignInInternalOptions.m | 10 +- .../{GIDTokenClaim.h => GIDClaim.h} | 2 +- .../Sources/Public/GoogleSignIn/GIDSignIn.h | 50 +++---- .../Public/GoogleSignIn/GoogleSignIn.h | 2 +- .../{GIDTokenClaimTest.m => GIDClaimTest.m} | 18 +-- ...sTest.m => GIDClaimsInternalOptionsTest.m} | 36 ++--- .../Tests/Unit/GIDSignInInternalOptionsTest.m | 10 +- GoogleSignIn/Tests/Unit/GIDSignInTest.m | 138 +++++++++--------- .../Services/GoogleSignInAuthenticator.swift | 6 +- 14 files changed, 210 insertions(+), 210 deletions(-) rename GoogleSignIn/Sources/{GIDTokenClaim.m => GIDClaim.m} (89%) rename GoogleSignIn/Sources/{GIDTokenClaimsInternalOptions.h => GIDClaimsInternalOptions.h} (75%) rename GoogleSignIn/Sources/{GIDTokenClaimsInternalOptions.m => GIDClaimsInternalOptions.m} (72%) rename GoogleSignIn/Sources/Public/GoogleSignIn/{GIDTokenClaim.h => GIDClaim.h} (97%) rename GoogleSignIn/Tests/Unit/{GIDTokenClaimTest.m => GIDClaimTest.m} (69%) rename GoogleSignIn/Tests/Unit/{GIDTokenClaimsInternalOptionsTest.m => GIDClaimsInternalOptionsTest.m} (70%) diff --git a/GoogleSignIn/Sources/GIDTokenClaim.m b/GoogleSignIn/Sources/GIDClaim.m similarity index 89% rename from GoogleSignIn/Sources/GIDTokenClaim.m rename to GoogleSignIn/Sources/GIDClaim.m index 61e83d6a..13792cae 100644 --- a/GoogleSignIn/Sources/GIDTokenClaim.m +++ b/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 @@ - (BOOL)isEqual:(id)object { } // 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; } diff --git a/GoogleSignIn/Sources/GIDTokenClaimsInternalOptions.h b/GoogleSignIn/Sources/GIDClaimsInternalOptions.h similarity index 75% rename from GoogleSignIn/Sources/GIDTokenClaimsInternalOptions.h rename to GoogleSignIn/Sources/GIDClaimsInternalOptions.h index adc56dd1..5306bcff 100644 --- a/GoogleSignIn/Sources/GIDTokenClaimsInternalOptions.h +++ b/GoogleSignIn/Sources/GIDClaimsInternalOptions.h @@ -16,21 +16,21 @@ #import -@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)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 *)claims +- (nullable NSString *)validatedJSONStringForClaims:(nullable NSSet *)claims error:(NSError *_Nullable *_Nullable)error; @end diff --git a/GoogleSignIn/Sources/GIDTokenClaimsInternalOptions.m b/GoogleSignIn/Sources/GIDClaimsInternalOptions.m similarity index 72% rename from GoogleSignIn/Sources/GIDTokenClaimsInternalOptions.m rename to GoogleSignIn/Sources/GIDClaimsInternalOptions.m index 049f00e1..28649325 100644 --- a/GoogleSignIn/Sources/GIDTokenClaimsInternalOptions.m +++ b/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 jsonSerializer; @end -@implementation GIDTokenClaimsInternalOptions +@implementation GIDClaimsInternalOptions - (instancetype)init { return [self initWithJSONSerializer:[[GIDJSONSerializerImpl alloc] init]]; @@ -44,18 +44,18 @@ - (instancetype)initWithJSONSerializer:(id)jsonSerializer { return self; } -- (nullable NSString *)validatedJSONStringForClaims:(nullable NSSet *)claims +- (nullable NSString *)validatedJSONStringForClaims:(nullable NSSet *)claims error:(NSError *_Nullable *_Nullable)error { if (!claims || claims.count == 0) { return nil; } // === Step 1: Check for claims with ambiguous essential property. === - NSMutableDictionary *validTokenClaims = + NSMutableDictionary *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 @@ - (nullable NSString *)validatedJSONStringForClaims:(nullable NSSet *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 *finalRequestDictionary = - @{ kGIDTokenClaimKeyName: tokenClaimsDictionary }; + @{ kGIDClaimKeyName: tokenClaimsDictionary }; // === Step 3: Serialize the final dictionary into a JSON string === return [_jsonSerializer stringWithJSONObject:finalRequestDictionary error:error]; diff --git a/GoogleSignIn/Sources/GIDSignIn.m b/GoogleSignIn/Sources/GIDSignIn.m index ff4fcdae..138337c2 100644 --- a/GoogleSignIn/Sources/GIDSignIn.m +++ b/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 #import "GoogleSignIn/Sources/GIDAppCheck/Implementations/GIDAppCheck.h" @@ -138,7 +138,7 @@ 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 @@ @implementation GIDSignIn { // 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 @@ - (void)signInWithPresentingViewController:(UIViewController *)presentingViewCon hint:hint additionalScopes:additionalScopes nonce:nonce - tokenClaims:nil + claims:nil completion:completion]; } - (void)signInWithPresentingViewController:(UIViewController *)presentingViewController - tokenClaims:(nullable NSSet *)tokenClaims + claims:(nullable NSSet *)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 *)tokenClaims + claims:(nullable NSSet *)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 *)additionalScopes - tokenClaims:(nullable NSSet *)tokenClaims + claims:(nullable NSSet *)claims completion:(nullable GIDSignInCompletion)completion { [self signInWithPresentingViewController:presentingViewController hint:hint additionalScopes:additionalScopes nonce:nil - tokenClaims:tokenClaims + claims:claims completion:completion]; } @@ -335,7 +335,7 @@ - (void)signInWithPresentingViewController:(UIViewController *)presentingViewCon hint:(nullable NSString *)hint additionalScopes:(nullable NSArray *)additionalScopes nonce:(nullable NSString *)nonce - tokenClaims:(nullable NSSet *)tokenClaims + claims:(nullable NSSet *)claims completion:(nullable GIDSignInCompletion)completion { GIDSignInInternalOptions *options = [GIDSignInInternalOptions defaultOptionsWithConfiguration:_configuration @@ -344,7 +344,7 @@ - (void)signInWithPresentingViewController:(UIViewController *)presentingViewCon addScopesFlow:NO scopes:additionalScopes nonce:nonce - tokenClaims:tokenClaims + claims:claims completion:completion]; [self signInWithOptions:options]; } @@ -369,10 +369,10 @@ - (void)addScopes:(NSArray *)scopes 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 *requestedScopes = [NSSet setWithArray:scopes]; @@ -441,40 +441,40 @@ - (void)signInWithPresentingWindow:(NSWindow *)presentingWindow hint:hint additionalScopes:additionalScopes nonce:nonce - tokenClaims:nil + claims:nil completion:completion]; } - (void)signInWithPresentingWindow:(NSWindow *)presentingWindow - tokenClaims:(nullable NSSet *)tokenClaims + claims:(nullable NSSet *)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 *)tokenClaims + claims:(nullable NSSet *)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 *)additionalScopes - tokenClaims:(nullable NSSet *)tokenClaims + claims:(nullable NSSet *)claims completion:(nullable GIDSignInCompletion)completion { [self signInWithPresentingWindow:presentingWindow hint:hint additionalScopes:additionalScopes nonce:nil - tokenClaims:tokenClaims + claims:claims completion:completion]; } @@ -482,7 +482,7 @@ - (void)signInWithPresentingWindow:(NSWindow *)presentingWindow hint:(nullable NSString *)hint additionalScopes:(nullable NSArray *)additionalScopes nonce:(nullable NSString *)nonce - tokenClaims:(nullable NSSet *)tokenClaims + claims:(nullable NSSet *)claims completion:(nullable GIDSignInCompletion)completion { GIDSignInInternalOptions *options = [GIDSignInInternalOptions defaultOptionsWithConfiguration:_configuration @@ -491,7 +491,7 @@ - (void)signInWithPresentingWindow:(NSWindow *)presentingWindow addScopesFlow:NO scopes:additionalScopes nonce:nonce - tokenClaims:tokenClaims + claims:claims completion:completion]; [self signInWithOptions:options]; } @@ -509,10 +509,10 @@ - (void)addScopes:(NSArray *)scopes 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 *requestedScopes = [NSSet setWithArray:scopes]; @@ -660,7 +660,7 @@ - (instancetype)initWithKeychainStore:(GTMKeychainStore *)keychainStore 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 @@ - (void)signInWithOptions:(GIDSignInInternalOptions *)options { } }]; } 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 @@ - (void)authorizationRequestWithOptions:(GIDSignInInternalOptions *)options comp 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 diff --git a/GoogleSignIn/Sources/GIDSignInInternalOptions.h b/GoogleSignIn/Sources/GIDSignInInternalOptions.h index f21d75d7..9e3b7ce0 100644 --- a/GoogleSignIn/Sources/GIDSignInInternalOptions.h +++ b/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 *tokenClaims; +/// The claims requested by the Clients. +@property(nonatomic, readonly, copy, nullable) NSSet *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 diff --git a/GoogleSignIn/Sources/GIDSignInInternalOptions.m b/GoogleSignIn/Sources/GIDSignInInternalOptions.m index 0799906a..4a87bddf 100644 --- a/GoogleSignIn/Sources/GIDSignInInternalOptions.m +++ b/GoogleSignIn/Sources/GIDSignInInternalOptions.m @@ -32,7 +32,7 @@ + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)con 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 @@ + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)con 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 @@ + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)con options->_completion = completion; options->_scopes = [GIDScopes scopesWithBasicProfile:scopes]; options->_nonce = nonce; - options->_tokenClaims = tokenClaims; + options->_claims = claims; } return options; } @@ -87,7 +87,7 @@ + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)con addScopesFlow:addScopesFlow scopes:@[] nonce:nil - tokenClaims:nil + claims:nil completion:completion]; return options; } @@ -124,7 +124,7 @@ - (instancetype)optionsWithExtraParameters:(NSDictionary *)extraParams options->_loginHint = _loginHint; options->_completion = _completion; options->_scopes = _scopes; - options->_tokenClaims = _tokenClaims; + options->_claims = _claims; options->_extraParams = [extraParams copy]; } return options; diff --git a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDTokenClaim.h b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDClaim.h similarity index 97% rename from GoogleSignIn/Sources/Public/GoogleSignIn/GIDTokenClaim.h rename to GoogleSignIn/Sources/Public/GoogleSignIn/GIDClaim.h index 7a2351cb..bc266930 100644 --- a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDTokenClaim.h +++ b/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; diff --git a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h index 768d1764..c02d97f8 100644 --- a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h +++ b/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 *)tokenClaims + claims:(nullable NSSet *)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 *)tokenClaims + claims:(nullable NSSet *)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 *)additionalScopes - tokenClaims:(nullable NSSet *)tokenClaims + claims:(nullable NSSet *)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 *)additionalScopes nonce:(nullable NSString *)nonce - tokenClaims:(nullable NSSet *)tokenClaims + claims:(nullable NSSet *)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 *)tokenClaims + claims:(nullable NSSet *)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 *)tokenClaims + claims:(nullable NSSet *)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 *)additionalScopes - tokenClaims:(nullable NSSet *)tokenClaims + claims:(nullable NSSet *)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 *)additionalScopes nonce:(nullable NSString *)nonce - tokenClaims:(nullable NSSet *)tokenClaims + claims:(nullable NSSet *)claims completion:(nullable void (^)(GIDSignInResult *_Nullable signInResult, NSError *_Nullable error))completion; diff --git a/GoogleSignIn/Sources/Public/GoogleSignIn/GoogleSignIn.h b/GoogleSignIn/Sources/Public/GoogleSignIn/GoogleSignIn.h index 02935be8..2f25ae60 100644 --- a/GoogleSignIn/Sources/Public/GoogleSignIn/GoogleSignIn.h +++ b/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 diff --git a/GoogleSignIn/Tests/Unit/GIDTokenClaimTest.m b/GoogleSignIn/Tests/Unit/GIDClaimTest.m similarity index 69% rename from GoogleSignIn/Tests/Unit/GIDTokenClaimTest.m rename to GoogleSignIn/Tests/Unit/GIDClaimTest.m index 145e46f6..e014d885 100644 --- a/GoogleSignIn/Tests/Unit/GIDTokenClaimTest.m +++ b/GoogleSignIn/Tests/Unit/GIDClaimTest.m @@ -14,35 +14,35 @@ #import -#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); } diff --git a/GoogleSignIn/Tests/Unit/GIDTokenClaimsInternalOptionsTest.m b/GoogleSignIn/Tests/Unit/GIDClaimsInternalOptionsTest.m similarity index 70% rename from GoogleSignIn/Tests/Unit/GIDTokenClaimsInternalOptionsTest.m rename to GoogleSignIn/Tests/Unit/GIDClaimsInternalOptionsTest.m index 4c90998f..93b6acc5 100644 --- a/GoogleSignIn/Tests/Unit/GIDTokenClaimsInternalOptionsTest.m +++ b/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 @@ - (void)testValidatedJSONStringForClaims_WithEssentialClaim_IsCorrectlyFormatted #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 @@ - (void)testValidatedJSONStringForClaims_WithConflictingClaims_ReturnsNilAndPopu } - (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 @@ - (void)testValidatedJSONStringForClaims_WhenSerializationFails_ReturnsNilAndErr }]; _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."); diff --git a/GoogleSignIn/Tests/Unit/GIDSignInInternalOptionsTest.m b/GoogleSignIn/Tests/Unit/GIDSignInInternalOptionsTest.m index 1d6c2b3c..13fcac4d 100644 --- a/GoogleSignIn/Tests/Unit/GIDSignInInternalOptionsTest.m +++ b/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 @@ - (void)testDefaultOptions_withAllParameters_initializesPropertiesCorrectly { NSString *loginHint = @"login_hint"; NSArray *scopes = @[@"scope1", @"scope2"]; NSString *nonce = @"test_nonce"; - NSSet *tokenClaims = [NSSet setWithObject:[GIDTokenClaim authTimeClaim]]; + NSSet *claims = [NSSet setWithObject:[GIDClaim authTimeClaim]]; NSArray *expectedScopes = @[@"scope1", @"scope2", @"email", @"profile"]; GIDSignInCompletion completion = ^(GIDSignInResult *_Nullable signInResult, @@ -90,7 +90,7 @@ - (void)testDefaultOptions_withAllParameters_initializesPropertiesCorrectly { addScopesFlow:NO scopes:scopes nonce:nonce - tokenClaims:tokenClaims + claims:claims completion:completion]; XCTAssertTrue(options.interactive); XCTAssertFalse(options.continuation); @@ -100,8 +100,8 @@ - (void)testDefaultOptions_withAllParameters_initializesPropertiesCorrectly { // 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 diff --git a/GoogleSignIn/Tests/Unit/GIDSignInTest.m b/GoogleSignIn/Tests/Unit/GIDSignInTest.m index 55f239d0..e214eaee 100644 --- a/GoogleSignIn/Tests/Unit/GIDSignInTest.m +++ b/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 @@ -644,7 +644,7 @@ - (void)testOAuthLogin { authError:nil tokenError:nil emmPasscodeInfoRequired:NO - tokenClaimsAsJSONRequired:NO + claimsAsJSONRequired:NO keychainError:NO restoredSignIn:NO oldAccessToken:NO @@ -662,7 +662,7 @@ - (void)testOAuthLogin_RestoredSignIn { authError:nil tokenError:nil emmPasscodeInfoRequired:NO - tokenClaimsAsJSONRequired:NO + claimsAsJSONRequired:NO keychainError:NO restoredSignIn:YES oldAccessToken:NO @@ -680,7 +680,7 @@ - (void)testOAuthLogin_RestoredSignInOldAccessToken { authError:nil tokenError:nil emmPasscodeInfoRequired:NO - tokenClaimsAsJSONRequired:NO + claimsAsJSONRequired:NO keychainError:NO restoredSignIn:YES oldAccessToken:YES @@ -700,16 +700,16 @@ - (void)testOAuthLogin_AdditionalScopes { 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 @@ - (void)testOAuthLogin_AdditionalScopes { 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 @@ - (void)testOAuthLogin_AdditionalScopes { 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 @@ - (void)testOAuthLogin_WithTokenClaims_FormatsParametersCorrectly { 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 @@ - (void)testOAuthLogin_WithTokenClaims_FormatsParametersCorrectly { 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 @@ - (void)testOAuthLogin_WithTokenClaims_ReturnsIdTokenWithCorrectClaims { 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 @@ - (void)testAddScopes { authError:nil tokenError:nil emmPasscodeInfoRequired:NO - tokenClaimsAsJSONRequired:NO + claimsAsJSONRequired:NO keychainError:NO restoredSignIn:YES oldAccessToken:NO @@ -872,7 +872,7 @@ - (void)testAddScopes { authError:nil tokenError:nil emmPasscodeInfoRequired:NO - tokenClaimsAsJSONRequired:NO + claimsAsJSONRequired:NO keychainError:NO restoredSignIn:NO oldAccessToken:NO @@ -901,7 +901,7 @@ - (void)testAddScopes { } - (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 @@ - (void)testAddScopes_WithPreviouslyRequestedClaims { 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 @@ - (void)testAddScopes_WithPreviouslyRequestedClaims { authError:nil tokenError:nil emmPasscodeInfoRequired:NO - tokenClaimsAsJSONRequired:YES + claimsAsJSONRequired:YES keychainError:NO restoredSignIn:NO oldAccessToken:NO @@ -986,7 +986,7 @@ - (void)testOpenIDRealm { authError:nil tokenError:nil emmPasscodeInfoRequired:NO - tokenClaimsAsJSONRequired:NO + claimsAsJSONRequired:NO keychainError:NO restoredSignIn:NO oldAccessToken:NO @@ -1014,16 +1014,16 @@ - (void)testManualNonce { 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 @@ - (void)testOAuthLogin_LoginHint { authError:nil tokenError:nil emmPasscodeInfoRequired:NO - tokenClaimsAsJSONRequired:NO + claimsAsJSONRequired:NO keychainError:NO restoredSignIn:NO oldAccessToken:NO @@ -1069,7 +1069,7 @@ - (void)testOAuthLogin_HostedDomain { authError:nil tokenError:nil emmPasscodeInfoRequired:NO - tokenClaimsAsJSONRequired:NO + claimsAsJSONRequired:NO keychainError:NO restoredSignIn:NO oldAccessToken:NO @@ -1084,7 +1084,7 @@ - (void)testOAuthLogin_ConsentCanceled { authError:@"access_denied" tokenError:nil emmPasscodeInfoRequired:NO - tokenClaimsAsJSONRequired:NO + claimsAsJSONRequired:NO keychainError:NO restoredSignIn:NO oldAccessToken:NO @@ -1099,7 +1099,7 @@ - (void)testOAuthLogin_ModalCanceled { authError:nil tokenError:nil emmPasscodeInfoRequired:NO - tokenClaimsAsJSONRequired:NO + claimsAsJSONRequired:NO keychainError:NO restoredSignIn:NO oldAccessToken:NO @@ -1124,7 +1124,7 @@ - (void)testOAuthLogin_KeychainError { authError:nil tokenError:nil emmPasscodeInfoRequired:NO - tokenClaimsAsJSONRequired:NO + claimsAsJSONRequired:NO keychainError:YES restoredSignIn:NO oldAccessToken:NO @@ -1136,25 +1136,25 @@ - (void)testOAuthLogin_KeychainError { 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 @@ - (void)testOAuthLogin_TokenClaims_FailsWithError { @"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 @@ - (void)testSignOut { authError:nil tokenError:nil emmPasscodeInfoRequired:NO - tokenClaimsAsJSONRequired:NO + claimsAsJSONRequired:NO keychainError:NO restoredSignIn:YES oldAccessToken:NO @@ -1430,7 +1430,7 @@ - (void)testEmmSupportRequestParameters { authError:nil tokenError:nil emmPasscodeInfoRequired:NO - tokenClaimsAsJSONRequired:NO + claimsAsJSONRequired:NO keychainError:NO restoredSignIn:NO oldAccessToken:NO @@ -1482,7 +1482,7 @@ - (void)testEmmPasscodeInfo { authError:nil tokenError:nil emmPasscodeInfoRequired:YES - tokenClaimsAsJSONRequired:NO + claimsAsJSONRequired:NO keychainError:NO restoredSignIn:NO oldAccessToken:NO @@ -1514,7 +1514,7 @@ - (void)testAuthEndpointEMMError { authError:callbackParams[@"error"] tokenError:nil emmPasscodeInfoRequired:NO - tokenClaimsAsJSONRequired:NO + claimsAsJSONRequired:NO keychainError:NO restoredSignIn:NO oldAccessToken:NO @@ -1552,7 +1552,7 @@ - (void)testTokenEndpointEMMError { authError:nil tokenError:emmError emmPasscodeInfoRequired:NO - tokenClaimsAsJSONRequired:NO + claimsAsJSONRequired:NO keychainError:NO restoredSignIn:NO oldAccessToken:NO @@ -1637,7 +1637,7 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow 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 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow 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 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow 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 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow NSDictionary *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 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow 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 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow 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 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow - (NSDictionary *) additionalParametersWithEMMPasscodeInfoRequired:(BOOL)emmPasscodeInfoRequired - tokenClaimsAsJSONRequired:(BOOL)tokenClaimsAsJSONRequired { + claimsAsJSONRequired:(BOOL)claimsAsJSONRequired { NSMutableDictionary *additionalParameters = [NSMutableDictionary dictionary]; if (emmPasscodeInfoRequired) { additionalParameters[@"emm_passcode_info_required"] = @"1"; } - if (tokenClaimsAsJSONRequired) { + if (claimsAsJSONRequired) { additionalParameters[@"claims"] = kNonEssentialAuthTimeClaimsJsonString; } diff --git a/Samples/Swift/DaysUntilBirthday/Shared/Services/GoogleSignInAuthenticator.swift b/Samples/Swift/DaysUntilBirthday/Shared/Services/GoogleSignInAuthenticator.swift index 88d00f2e..afa9ba49 100644 --- a/Samples/Swift/DaysUntilBirthday/Shared/Services/GoogleSignInAuthenticator.swift +++ b/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 = Set([GIDTokenClaim.authTime()]) + private var claims: Set = 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))") From 22d4f9c91e33a0b81026859ff2bd30bf9f514946 Mon Sep 17 00:00:00 2001 From: Akshat Gandhi <54901287+AkshatG6@users.noreply.github.com> Date: Fri, 26 Sep 2025 12:11:12 -0700 Subject: [PATCH 2/2] Additional renaming of tokenClaims to claims --- GoogleSignIn/Sources/GIDClaimsInternalOptions.m | 8 ++++---- GoogleSignIn/Tests/Unit/GIDSignInTest.m | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/GoogleSignIn/Sources/GIDClaimsInternalOptions.m b/GoogleSignIn/Sources/GIDClaimsInternalOptions.m index 28649325..44a01cf0 100644 --- a/GoogleSignIn/Sources/GIDClaimsInternalOptions.m +++ b/GoogleSignIn/Sources/GIDClaimsInternalOptions.m @@ -72,17 +72,17 @@ - (nullable NSString *)validatedJSONStringForClaims:(nullable NSSet } // === Step 2: Build the dictionary structure required for OIDC JSON === - NSMutableDictionary *tokenClaimsDictionary = + NSMutableDictionary *claimsDictionary = [[NSMutableDictionary alloc] init]; for (GIDClaim *claim in validClaims.allValues) { if (claim.isEssential) { - tokenClaimsDictionary[claim.name] = @{ kGIDClaimEssentialPropertyKey: @YES }; + claimsDictionary[claim.name] = @{ kGIDClaimEssentialPropertyKey: @YES }; } else { - tokenClaimsDictionary[claim.name] = @{ kGIDClaimEssentialPropertyKey: @NO }; + claimsDictionary[claim.name] = @{ kGIDClaimEssentialPropertyKey: @NO }; } } NSDictionary *finalRequestDictionary = - @{ kGIDClaimKeyName: tokenClaimsDictionary }; + @{ kGIDClaimKeyName: claimsDictionary }; // === Step 3: Serialize the final dictionary into a JSON string === return [_jsonSerializer stringWithJSONObject:finalRequestDictionary error:error]; diff --git a/GoogleSignIn/Tests/Unit/GIDSignInTest.m b/GoogleSignIn/Tests/Unit/GIDSignInTest.m index e214eaee..13b4435e 100644 --- a/GoogleSignIn/Tests/Unit/GIDSignInTest.m +++ b/GoogleSignIn/Tests/Unit/GIDSignInTest.m @@ -921,7 +921,7 @@ - (void)testAddScopes_WithPreviouslyRequestedClaims { useAdditionalScopes:NO additionalScopes:nil manualNonce:nil - claims:[NSSet setWithObject:authTimeClaim]]; + claims:[NSSet setWithObject:authTimeClaim]]; XCTAssertNotNil(_signIn.currentUser);