Skip to content

Commit f03d0ef

Browse files
committed
Remove Firebase specifics from GACAppCheck (#11368)
Removed Firebase-specific symbols and implementation details from the generic GACAppCheck.
1 parent 13d188a commit f03d0ef

File tree

11 files changed

+105
-227
lines changed

11 files changed

+105
-227
lines changed

AppCheck.podspec

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ Pod::Spec.new do |s|
3737
s.source_files = [
3838
base_dir + 'Sources/**/*.[mh]',
3939
base_dir + 'Interop/*.h',
40-
'FirebaseCore/Extension/*.h',
4140
]
4241
s.public_header_files = base_dir + 'Sources/Public/AppCheck/*.h'
4342

@@ -46,7 +45,6 @@ Pod::Spec.new do |s|
4645
s.tvos.weak_framework = 'DeviceCheck'
4746

4847
s.dependency 'AppCheckInterop', '~> 10.11'
49-
s.dependency 'FirebaseCore', '~> 10.0'
5048
s.dependency 'PromisesObjC', '~> 2.1'
5149
s.dependency 'GoogleUtilities/Environment', '~> 7.8'
5250

@@ -72,6 +70,7 @@ Pod::Spec.new do |s|
7270
]
7371

7472
unit_tests.resources = base_dir + 'Tests/Fixture/**/*'
73+
unit_tests.dependency 'FirebaseCore', '~> 10.0'
7574
unit_tests.dependency 'OCMock'
7675
unit_tests.dependency 'HeartbeatLoggingTestUtils'
7776
unit_tests.requires_app_host = true
@@ -89,6 +88,7 @@ Pod::Spec.new do |s|
8988
base_dir + 'Tests/Integration/**/*.[mh]',
9089
]
9190
integration_tests.resources = base_dir + 'Tests/Fixture/**/*'
91+
integration_tests.dependency 'FirebaseCore', '~> 10.0'
9292
integration_tests.requires_app_host = true
9393
end
9494

@@ -102,6 +102,7 @@ Pod::Spec.new do |s|
102102
base_dir + 'Tests/Unit/Swift/**/*.swift',
103103
base_dir + 'Tests/Unit/Swift/**/*.h',
104104
]
105+
swift_unit_tests.dependency 'FirebaseCore', '~> 10.0'
105106
end
106107

107108
end

AppCheck/Interop/GACAppCheckInterop.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ NS_SWIFT_NAME(InternalAppCheckInterop) @protocol GACAppCheckInterop
4141
- (NSString *)notificationTokenKey;
4242
/// `userInfo` key for the `FirebaseApp.name` in a notification for
4343
/// `tokenDidChangeNotificationName`.
44-
- (NSString *)notificationAppNameKey;
44+
- (NSString *)notificationInstanceNameKey;
4545

4646
// MARK: - Optional API
4747

AppCheck/Sources/Core/GACAppCheck.m

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737
#import "AppCheck/Interop/GACAppCheckInterop.h"
3838
#import "AppCheck/Interop/GACAppCheckTokenResultInterop.h"
3939

40-
#import "FirebaseCore/Extension/FirebaseCoreInternal.h"
41-
4240
NS_ASSUME_NONNULL_BEGIN
4341

4442
/// A notification with the specified name is sent to the default notification center
@@ -51,8 +49,8 @@
5149
/// `userInfo` key for the `AppCheckToken` in `appCheckTokenRefreshNotification`.
5250
NSString *const kGACAppCheckTokenNotificationKey = @"GACAppCheckTokenNotificationKey";
5351

54-
/// `userInfo` key for the `FirebaseApp.name` in `appCheckTokenRefreshNotification`.
55-
NSString *const kGACAppCheckAppNameNotificationKey = @"GACAppCheckAppNameNotificationKey";
52+
/// `userInfo` key for the instance name in `appCheckTokenRefreshNotification`.
53+
NSString *const kGACAppCheckInstanceNameNotificationKey = @"GACAppCheckInstanceNameNotificationKey";
5654

5755
// TODO(andrewheard): Remove from generic App Check SDK.
5856
// FIREBASE_APP_CHECK_ONLY_BEGIN
@@ -68,7 +66,7 @@
6866

6967
@interface GACAppCheck ()
7068

71-
@property(nonatomic, readonly) NSString *appName;
69+
@property(nonatomic, readonly) NSString *instanceName;
7270
@property(nonatomic, readonly) id<GACAppCheckProvider> appCheckProvider;
7371
@property(nonatomic, readonly) id<GACAppCheckStorageProtocol> storage;
7472
@property(nonatomic, readonly) NSNotificationCenter *notificationCenter;
@@ -84,15 +82,15 @@ @implementation GACAppCheck
8482

8583
#pragma mark - Internal
8684

87-
- (instancetype)initWithAppName:(NSString *)appName
88-
appCheckProvider:(id<GACAppCheckProvider>)appCheckProvider
89-
storage:(id<GACAppCheckStorageProtocol>)storage
90-
tokenRefresher:(id<GACAppCheckTokenRefresherProtocol>)tokenRefresher
91-
notificationCenter:(NSNotificationCenter *)notificationCenter
92-
settings:(id<GACAppCheckSettingsProtocol>)settings {
85+
- (instancetype)initWithInstanceName:(NSString *)instanceName
86+
appCheckProvider:(id<GACAppCheckProvider>)appCheckProvider
87+
storage:(id<GACAppCheckStorageProtocol>)storage
88+
tokenRefresher:(id<GACAppCheckTokenRefresherProtocol>)tokenRefresher
89+
notificationCenter:(NSNotificationCenter *)notificationCenter
90+
settings:(id<GACAppCheckSettingsProtocol>)settings {
9391
self = [super init];
9492
if (self) {
95-
_appName = appName;
93+
_instanceName = instanceName;
9694
_appCheckProvider = appCheckProvider;
9795
_storage = storage;
9896
_tokenRefresher = tokenRefresher;
@@ -110,28 +108,27 @@ - (instancetype)initWithAppName:(NSString *)appName
110108

111109
#pragma mark - Public
112110

113-
- (instancetype)initWithApp:(FIRApp *)app
114-
appCheckProvider:(id<GACAppCheckProvider>)appCheckProvider
115-
settings:(id<GACAppCheckSettingsProtocol>)settings {
111+
- (instancetype)initWithInstanceName:(NSString *)instanceName
112+
appCheckProvider:(id<GACAppCheckProvider>)appCheckProvider
113+
settings:(id<GACAppCheckSettingsProtocol>)settings
114+
resourceName:(NSString *)resourceName
115+
keychainAccessGroup:(nullable NSString *)accessGroup {
116116
GACAppCheckTokenRefreshResult *refreshResult =
117117
[[GACAppCheckTokenRefreshResult alloc] initWithStatusNever];
118118
GACAppCheckTokenRefresher *tokenRefresher =
119119
[[GACAppCheckTokenRefresher alloc] initWithRefreshResult:refreshResult settings:settings];
120120

121-
// TODO(andrewheard): Remove from generic App Check SDK.
122-
// FIREBASE_APP_CHECK_ONLY_BEGIN
123121
NSString *tokenKey =
124-
[NSString stringWithFormat:@"app_check_token.%@.%@", app.name, app.options.googleAppID];
125-
// FIREBASE_APP_CHECK_ONLY_END
126-
GACAppCheckStorage *storage =
127-
[[GACAppCheckStorage alloc] initWithTokenKey:tokenKey accessGroup:app.options.appGroupID];
128-
129-
return [self initWithAppName:app.name
130-
appCheckProvider:appCheckProvider
131-
storage:storage
132-
tokenRefresher:tokenRefresher
133-
notificationCenter:NSNotificationCenter.defaultCenter
134-
settings:settings];
122+
[NSString stringWithFormat:@"app_check_token.%@.%@", instanceName, resourceName];
123+
GACAppCheckStorage *storage = [[GACAppCheckStorage alloc] initWithTokenKey:tokenKey
124+
accessGroup:accessGroup];
125+
126+
return [self initWithInstanceName:instanceName
127+
appCheckProvider:appCheckProvider
128+
storage:storage
129+
tokenRefresher:tokenRefresher
130+
notificationCenter:NSNotificationCenter.defaultCenter
131+
settings:settings];
135132
}
136133

137134
- (void)tokenForcingRefresh:(BOOL)forcingRefresh
@@ -204,8 +201,8 @@ - (nonnull NSString *)tokenDidChangeNotificationName {
204201
return GACAppCheckAppCheckTokenDidChangeNotification;
205202
}
206203

207-
- (nonnull NSString *)notificationAppNameKey {
208-
return kGACAppCheckAppNameNotificationKey;
204+
- (nonnull NSString *)notificationInstanceNameKey {
205+
return kGACAppCheckInstanceNameNotificationKey;
209206
}
210207

211208
- (nonnull NSString *)notificationTokenKey {
@@ -320,7 +317,7 @@ - (void)postTokenUpdateNotificationWithToken:(GACAppCheckToken *)token {
320317
object:self
321318
userInfo:@{
322319
kGACAppCheckTokenNotificationKey : token.token,
323-
kGACAppCheckAppNameNotificationKey : self.appName
320+
kGACAppCheckInstanceNameNotificationKey : self.instanceName
324321
}];
325322
}
326323

AppCheck/Sources/Core/GACAppCheckLogger.m

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
#import "AppCheck/Sources/Core/GACAppCheckLogger.h"
1818

19-
#import "FirebaseCore/Extension/FirebaseCoreInternal.h"
20-
2119
NS_ASSUME_NONNULL_BEGIN
2220

2321
#pragma mark - Log Message Codes

AppCheck/Sources/Core/GACAppCheckValidator.h

Lines changed: 0 additions & 35 deletions
This file was deleted.

AppCheck/Sources/Core/GACAppCheckValidator.m

Lines changed: 0 additions & 41 deletions
This file was deleted.

AppCheck/Sources/Core/Storage/GACAppCheckStoredToken.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
#import <Foundation/Foundation.h>
1818

19-
@class FIRApp;
20-
2119
NS_ASSUME_NONNULL_BEGIN
2220

2321
@interface GACAppCheckStoredToken : NSObject <NSSecureCoding>

AppCheck/Sources/Public/AppCheck/GACAppCheck.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
@import AppCheckInterop;
2020

21-
@class FIRApp;
2221
@class GACAppCheckToken;
2322
@protocol GACAppCheckProvider;
2423
@protocol GACAppCheckSettingsProtocol;
@@ -35,7 +34,7 @@ FOUNDATION_EXPORT const NSNotificationName
3534
/// `userInfo` key for the `FirebaseApp.name` in `AppCheckTokenDidChangeNotification`.
3635
FOUNDATION_EXPORT NSString *const kGACAppCheckTokenNotificationKey NS_SWIFT_NAME(InternalAppCheckTokenNotificationKey);
3736
/// `userInfo` key for the `AppCheckToken` in `AppCheckTokenDidChangeNotification`.
38-
FOUNDATION_EXPORT NSString *const kGACAppCheckAppNameNotificationKey NS_SWIFT_NAME(InternalAppCheckAppNameNotificationKey);
37+
FOUNDATION_EXPORT NSString *const kGACAppCheckInstanceNameNotificationKey NS_SWIFT_NAME(InternalAppCheckInstanceNameNotificationKey);
3938

4039
/// A class used to manage App Check tokens for a given resource.
4140
NS_SWIFT_NAME(InternalAppCheck)
@@ -44,12 +43,13 @@ NS_SWIFT_NAME(InternalAppCheck)
4443
- (instancetype)init NS_UNAVAILABLE;
4544

4645
/// Returns an instance of `AppCheck` for an application.
47-
/// @param app A configured `FirebaseApp` instance.
4846
/// @param appCheckProvider An `InternalAppCheckProvider` instance that provides App Check tokens.
4947
/// @return An instance of `AppCheck` corresponding to the provided `app`.
50-
- (instancetype)initWithApp:(FIRApp *)app
51-
appCheckProvider:(id<GACAppCheckProvider>)appCheckProvider
52-
settings:(id<GACAppCheckSettingsProtocol>)settings;
48+
- (instancetype)initWithInstanceName:(NSString *)instanceName
49+
appCheckProvider:(id<GACAppCheckProvider>)appCheckProvider
50+
settings:(id<GACAppCheckSettingsProtocol>)settings
51+
resourceName:(NSString *)resourceName
52+
keychainAccessGroup:(nullable NSString *)accessGroup;
5353

5454
/// Requests Firebase app check token. This method should *only* be used if you need to authorize
5555
/// requests to a non-Firebase backend. Requests to Firebase backend are authorized automatically if

0 commit comments

Comments
 (0)