From fe4b137399c974bd00a3fa31ff8165f78edad410 Mon Sep 17 00:00:00 2001 From: Andrew Heard Date: Mon, 24 Jul 2023 17:49:13 -0400 Subject: [PATCH] Remove App Check Core Interop SDK (#11595) The ObjC Protocol-only interop SDK is not needed by our integrators. --- AppCheckCore.podspec | 1 - AppCheckCore/Interop/CMakeLists.txt | 27 ---------- .../AppCheckCoreInterop/AppCheckCoreInterop.h | 18 ------- .../AppCheckCoreInterop/GACAppCheckInterop.h | 51 ------------------- .../GACAppCheckTokenInterop.h | 34 ------------- AppCheckCore/Interop/dummy.m | 17 ------- AppCheckCore/Sources/Core/GACAppCheck.m | 14 ++--- AppCheckCore/Sources/Core/GACAppCheckToken.m | 4 ++ .../Sources/Public/AppCheckCore/GACAppCheck.h | 29 +++++++++-- .../Public/AppCheckCore/GACAppCheckToken.h | 13 +++-- .../Tests/Unit/Core/GACAppCheckTests.m | 24 ++++----- AppCheckCoreInterop.podspec | 32 ------------ 12 files changed, 57 insertions(+), 207 deletions(-) delete mode 100644 AppCheckCore/Interop/CMakeLists.txt delete mode 100644 AppCheckCore/Interop/Public/AppCheckCoreInterop/AppCheckCoreInterop.h delete mode 100644 AppCheckCore/Interop/Public/AppCheckCoreInterop/GACAppCheckInterop.h delete mode 100644 AppCheckCore/Interop/Public/AppCheckCoreInterop/GACAppCheckTokenInterop.h delete mode 100644 AppCheckCore/Interop/dummy.m delete mode 100644 AppCheckCoreInterop.podspec diff --git a/AppCheckCore.podspec b/AppCheckCore.podspec index 7eec938..b195cf4 100644 --- a/AppCheckCore.podspec +++ b/AppCheckCore.podspec @@ -43,7 +43,6 @@ Pod::Spec.new do |s| s.osx.weak_framework = 'DeviceCheck' s.tvos.weak_framework = 'DeviceCheck' - s.dependency 'AppCheckCoreInterop', '~> 10.11' s.dependency 'PromisesObjC', '~> 2.1' s.dependency 'GoogleUtilities/Environment', '~> 7.8' diff --git a/AppCheckCore/Interop/CMakeLists.txt b/AppCheckCore/Interop/CMakeLists.txt deleted file mode 100644 index 0beb3cb..0000000 --- a/AppCheckCore/Interop/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2021 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -if(NOT APPLE) - return() -endif() - -file(GLOB headers *.h) -firebase_ios_generate_dummy_source(AppCheckInterop sources) - -firebase_ios_add_framework( - AppCheckInterop DISABLE_STRICT_WARNINGS EXCLUDE_FROM_ALL - ${headers} ${sources} -) - -firebase_ios_framework_public_headers(AppCheckInterop ${headers}) diff --git a/AppCheckCore/Interop/Public/AppCheckCoreInterop/AppCheckCoreInterop.h b/AppCheckCore/Interop/Public/AppCheckCoreInterop/AppCheckCoreInterop.h deleted file mode 100644 index 4b733fc..0000000 --- a/AppCheckCore/Interop/Public/AppCheckCoreInterop/AppCheckCoreInterop.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2023 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#import "GACAppCheckInterop.h" -#import "GACAppCheckTokenInterop.h" diff --git a/AppCheckCore/Interop/Public/AppCheckCoreInterop/GACAppCheckInterop.h b/AppCheckCore/Interop/Public/AppCheckCoreInterop/GACAppCheckInterop.h deleted file mode 100644 index 420f4a5..0000000 --- a/AppCheckCore/Interop/Public/AppCheckCoreInterop/GACAppCheckInterop.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#import - -@protocol GACAppCheckTokenInterop; - -NS_ASSUME_NONNULL_BEGIN - -NS_SWIFT_NAME(InternalAppCheckTokenHandlerInterop) -typedef void (^GACAppCheckTokenHandlerInterop)(id _Nullable token, - NSError *_Nullable error); - -NS_SWIFT_NAME(InternalAppCheckInterop) @protocol GACAppCheckInterop - -/// Requests Firebase app check token. -/// -/// @param forcingRefresh If `YES`, a new Firebase app check token is requested and the token -/// cache is ignored. If `NO`, the cached token is used if it exists and has not expired yet. In -/// most cases, `NO` should be used. `YES` should only be used if the server explicitly returns an -/// error, indicating a revoked token. -/// @param handler The completion handler. Includes the app check token if the request succeeds, -/// or an error if the request fails. -- (void)getTokenForcingRefresh:(BOOL)forcingRefresh - completion:(void (^)(id _Nullable token, - NSError *_Nullable error))handler - NS_SWIFT_NAME(token(forcingRefresh:completion:)); - -/// Retrieve a new limited-use App Check token -/// -/// This method does not affect the token generation behavior of the -/// ``tokenForcingRefresh()`` method. -- (void)getLimitedUseTokenWithCompletion:(void (^)(id _Nullable token, - NSError *_Nullable error))handler; - -@end - -NS_ASSUME_NONNULL_END diff --git a/AppCheckCore/Interop/Public/AppCheckCoreInterop/GACAppCheckTokenInterop.h b/AppCheckCore/Interop/Public/AppCheckCoreInterop/GACAppCheckTokenInterop.h deleted file mode 100644 index d00eb9c..0000000 --- a/AppCheckCore/Interop/Public/AppCheckCoreInterop/GACAppCheckTokenInterop.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#import - -NS_ASSUME_NONNULL_BEGIN - -@protocol GACAppCheckTokenInterop - -/// A Firebase App Check token. -@property(nonatomic, readonly) NSString *token; - -/// The App Check token's expiration date in the device's local time. -@property(nonatomic, readonly) NSDate *expirationDate; - -/// The date when the App Check token was received in the device's local time. -@property(nonatomic, readonly) NSDate *receivedAtDate; - -@end - -NS_ASSUME_NONNULL_END diff --git a/AppCheckCore/Interop/dummy.m b/AppCheckCore/Interop/dummy.m deleted file mode 100644 index 2e503fe..0000000 --- a/AppCheckCore/Interop/dummy.m +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Swift Package Manager needs at least one source file. diff --git a/AppCheckCore/Sources/Core/GACAppCheck.m b/AppCheckCore/Sources/Core/GACAppCheck.m index 15b1ca7..6e75a5d 100644 --- a/AppCheckCore/Sources/Core/GACAppCheck.m +++ b/AppCheckCore/Sources/Core/GACAppCheck.m @@ -22,8 +22,6 @@ #import "FBLPromises.h" #endif -@import AppCheckCoreInterop; - #import "AppCheckCore/Sources/Public/AppCheckCore/GACAppCheckErrors.h" #import "AppCheckCore/Sources/Public/AppCheckCore/GACAppCheckProvider.h" #import "AppCheckCore/Sources/Public/AppCheckCore/GACAppCheckSettings.h" @@ -42,6 +40,9 @@ static const NSTimeInterval kTokenExpirationThreshold = 5 * 60; // 5 min. static NSString *const kDummyFACTokenValue = @"eyJlcnJvciI6IlVOS05PV05fRVJST1IifQ=="; +typedef void (^GACAppCheckTokenHandler)(id _Nullable token, + NSError *_Nullable error); + @interface GACAppCheck () @property(nonatomic, readonly) NSString *instanceName; @@ -112,10 +113,9 @@ static NSString *const kDummyFACTokenValue = @"eyJlcnJvciI6IlVOS05PV05fRVJST1Iif #pragma mark - GACAppCheckInterop -- (void)getTokenForcingRefresh:(BOOL)forcingRefresh - completion:(GACAppCheckTokenHandlerInterop)handler { +- (void)getTokenForcingRefresh:(BOOL)forcingRefresh completion:(GACAppCheckTokenHandler)handler { [self retrieveOrRefreshTokenForcingRefresh:forcingRefresh] - .then(^id _Nullable(GACAppCheckToken *token) { + .then(^id _Nullable(id token) { handler(token, nil); return token; }) @@ -124,9 +124,9 @@ static NSString *const kDummyFACTokenValue = @"eyJlcnJvciI6IlVOS05PV05fRVJST1Iif }); } -- (void)getLimitedUseTokenWithCompletion:(GACAppCheckTokenHandlerInterop)handler { +- (void)getLimitedUseTokenWithCompletion:(GACAppCheckTokenHandler)handler { [self limitedUseToken] - .then(^id _Nullable(GACAppCheckToken *token) { + .then(^id _Nullable(id token) { handler(token, nil); return token; }) diff --git a/AppCheckCore/Sources/Core/GACAppCheckToken.m b/AppCheckCore/Sources/Core/GACAppCheckToken.m index 712fe2a..c016a3f 100644 --- a/AppCheckCore/Sources/Core/GACAppCheckToken.m +++ b/AppCheckCore/Sources/Core/GACAppCheckToken.m @@ -20,6 +20,10 @@ NS_ASSUME_NONNULL_BEGIN @implementation GACAppCheckToken +@synthesize token = _token; +@synthesize expirationDate = _expirationDate; +@synthesize receivedAtDate = _receivedAtDate; + - (instancetype)initWithToken:(NSString *)token expirationDate:(NSDate *)expirationDate receivedAtDate:(NSDate *)receivedAtDate { diff --git a/AppCheckCore/Sources/Public/AppCheckCore/GACAppCheck.h b/AppCheckCore/Sources/Public/AppCheckCore/GACAppCheck.h index cf93da0..b2ac158 100644 --- a/AppCheckCore/Sources/Public/AppCheckCore/GACAppCheck.h +++ b/AppCheckCore/Sources/Public/AppCheckCore/GACAppCheck.h @@ -16,18 +16,41 @@ #import -@import AppCheckCoreInterop; - @class GACAppCheckToken; @protocol GACAppCheckProvider; @protocol GACAppCheckSettingsProtocol; @protocol GACAppCheckTokenDelegate; +@protocol GACAppCheckTokenProtocol; NS_ASSUME_NONNULL_BEGIN +NS_SWIFT_NAME(AppCheckCoreProtocol) @protocol GACAppCheckProtocol + +/// Requests Firebase app check token. +/// +/// @param forcingRefresh If `YES`, a new Firebase app check token is requested and the token +/// cache is ignored. If `NO`, the cached token is used if it exists and has not expired yet. In +/// most cases, `NO` should be used. `YES` should only be used if the server explicitly returns an +/// error, indicating a revoked token. +/// @param handler The completion handler. Includes the app check token if the request succeeds, +/// or an error if the request fails. +- (void)getTokenForcingRefresh:(BOOL)forcingRefresh + completion:(void (^)(id _Nullable token, + NSError *_Nullable error))handler + NS_SWIFT_NAME(token(forcingRefresh:completion:)); + +/// Retrieve a new limited-use App Check token +/// +/// This method does not affect the token generation behavior of the +/// ``tokenForcingRefresh()`` method. +- (void)getLimitedUseTokenWithCompletion:(void (^)(id _Nullable token, + NSError *_Nullable error))handler; + +@end + /// A class used to manage App Check tokens for a given resource. NS_SWIFT_NAME(AppCheckCore) -@interface GACAppCheck : NSObject +@interface GACAppCheck : NSObject - (instancetype)init NS_UNAVAILABLE; diff --git a/AppCheckCore/Sources/Public/AppCheckCore/GACAppCheckToken.h b/AppCheckCore/Sources/Public/AppCheckCore/GACAppCheckToken.h index 85fb7ad..8e0c47e 100644 --- a/AppCheckCore/Sources/Public/AppCheckCore/GACAppCheckToken.h +++ b/AppCheckCore/Sources/Public/AppCheckCore/GACAppCheckToken.h @@ -16,13 +16,10 @@ #import -@import AppCheckCoreInterop; - NS_ASSUME_NONNULL_BEGIN -/// An object representing a Firebase App Check token. -NS_SWIFT_NAME(AppCheckCoreToken) -@interface GACAppCheckToken : NSObject +NS_SWIFT_NAME(AppCheckCoreTokenProtocol) +@protocol GACAppCheckTokenProtocol /// A Firebase App Check token. @property(nonatomic, readonly) NSString *token; @@ -33,6 +30,12 @@ NS_SWIFT_NAME(AppCheckCoreToken) /// The date when the App Check token was received in the device's local time. @property(nonatomic, readonly) NSDate *receivedAtDate; +@end + +/// An object representing a Firebase App Check token. +NS_SWIFT_NAME(AppCheckCoreToken) +@interface GACAppCheckToken : NSObject + - (instancetype)init NS_UNAVAILABLE; /// Convenience initializer that uses the current device local time to set `receivedAtDate`. diff --git a/AppCheckCore/Tests/Unit/Core/GACAppCheckTests.m b/AppCheckCore/Tests/Unit/Core/GACAppCheckTests.m index e5a5657..0cc14cf 100644 --- a/AppCheckCore/Tests/Unit/Core/GACAppCheckTests.m +++ b/AppCheckCore/Tests/Unit/Core/GACAppCheckTests.m @@ -41,7 +41,7 @@ static NSString *const kResourceName = @"projects/test_project_id/apps/test_app_ static NSString *const kAppName = @"GACAppCheckTests"; static NSString *const kAppGroupID = @"app_group_id"; -@interface GACAppCheck (Tests) +@interface GACAppCheck (Tests) - (instancetype)initWithInstanceName:(NSString *)instanceName appCheckProvider:(id)appCheckProvider @@ -59,7 +59,7 @@ static NSString *const kAppGroupID = @"app_group_id"; @property(nonatomic) OCMockObject *mockTokenRefresher; @property(nonatomic) OCMockObject *mockSettings; @property(nonatomic) OCMockObject *mockTokenDelegate; -@property(nonatomic) GACAppCheck *appCheck; +@property(nonatomic) GACAppCheck *appCheck; @property(nonatomic, copy, nullable) GACAppCheckTokenRefreshBlock tokenRefreshHandler; @@ -184,7 +184,7 @@ static NSString *const kAppGroupID = @"app_group_id"; // 2. Request token and verify result. [self.appCheck getTokenForcingRefresh:NO - completion:^(id _Nullable token, NSError *error) { + completion:^(id _Nullable token, NSError *error) { [expectation fulfill]; XCTAssertNotNil(token); XCTAssertEqualObjects(token.token, expectedToken.token); @@ -210,7 +210,7 @@ static NSString *const kAppGroupID = @"app_group_id"; // 2. Request token and verify result. [self.appCheck getTokenForcingRefresh:YES - completion:^(id _Nullable token, NSError *error) { + completion:^(id _Nullable token, NSError *error) { [expectation fulfill]; XCTAssertNotNil(token); XCTAssertEqualObjects(token.token, expectedToken.token); @@ -232,7 +232,7 @@ static NSString *const kAppGroupID = @"app_group_id"; // 2. Request token and verify result. [self.appCheck getTokenForcingRefresh:NO - completion:^(id _Nullable token, NSError *error) { + completion:^(id _Nullable token, NSError *error) { [expectation fulfill]; XCTAssertNotNil(token); XCTAssertEqualObjects(token.token, expectedToken.token); @@ -255,7 +255,7 @@ static NSString *const kAppGroupID = @"app_group_id"; // 2. Request token and verify result. [self.appCheck getTokenForcingRefresh:NO - completion:^(id _Nullable token, NSError *error) { + completion:^(id _Nullable token, NSError *error) { [expectation fulfill]; XCTAssertNil(token); XCTAssertEqualObjects(error, providerError); @@ -357,7 +357,7 @@ static NSString *const kAppGroupID = @"app_group_id"; // 5. Expect token request to be completed. XCTestExpectation *getTokenExpectation = [self expectationWithDescription:@"getToken"]; - [self.appCheck getLimitedUseTokenWithCompletion:^(id _Nullable token, + [self.appCheck getLimitedUseTokenWithCompletion:^(id _Nullable token, NSError *_Nullable error) { [getTokenExpectation fulfill]; XCTAssertNotNil(token); @@ -386,7 +386,7 @@ static NSString *const kAppGroupID = @"app_group_id"; // 5. Expect token request to be completed. XCTestExpectation *getTokenExpectation = [self expectationWithDescription:@"getToken"]; - [self.appCheck getLimitedUseTokenWithCompletion:^(id _Nullable token, + [self.appCheck getLimitedUseTokenWithCompletion:^(id _Nullable token, NSError *_Nullable error) { [getTokenExpectation fulfill]; XCTAssertNotNil(error); @@ -426,7 +426,7 @@ static NSString *const kAppGroupID = @"app_group_id"; // 3.2. Request token and verify result. [self.appCheck getTokenForcingRefresh:NO - completion:^(id _Nullable token, NSError *error) { + completion:^(id _Nullable token, NSError *error) { [getTokenExpectation fulfill]; XCTAssertNotNil(token); XCTAssertEqualObjects(token.token, expectedToken.token); @@ -471,7 +471,7 @@ static NSString *const kAppGroupID = @"app_group_id"; // 3.2. Request token and verify result. [self.appCheck getTokenForcingRefresh:NO - completion:^(id _Nullable token, NSError *error) { + completion:^(id _Nullable token, NSError *error) { [getTokenExpectation fulfill]; XCTAssertNil(token); XCTAssertEqualObjects(error, storageError); @@ -522,7 +522,7 @@ static NSString *const kAppGroupID = @"app_group_id"; // 2. Request token and verify result. [self.appCheck getTokenForcingRefresh:NO - completion:^(id _Nullable token, + completion:^(id _Nullable token, NSError *_Nullable error) { [expectation fulfill]; XCTAssertNotNil(token); @@ -545,7 +545,7 @@ static NSString *const kAppGroupID = @"app_group_id"; // 2. Request token and verify result. [self.appCheck getTokenForcingRefresh:NO - completion:^(id _Nullable token, NSError *error) { + completion:^(id _Nullable token, NSError *error) { [expectation fulfill]; XCTAssertNotNil(token); XCTAssertEqualObjects(token.token, cachedToken.token); diff --git a/AppCheckCoreInterop.podspec b/AppCheckCoreInterop.podspec deleted file mode 100644 index 56d8e68..0000000 --- a/AppCheckCoreInterop.podspec +++ /dev/null @@ -1,32 +0,0 @@ -Pod::Spec.new do |s| - s.name = 'AppCheckCoreInterop' - s.version = '10.13.0' - s.summary = 'Interfaces that allow other SDKs to use AppCheckCore functionality.' - - s.description = <<-DESC - Not for public use. - A set of protocols that other SDKs can use to interoperate with AppCheckCore in a safe - and reliable manner. - DESC - - s.homepage = 'https://firebase.google.com' - s.license = { :type => 'Apache-2.0', :file => 'LICENSE' } - s.authors = 'Google, Inc.' - - # NOTE that these should not be used externally, this is for Firebase pods to depend on each - # other. - s.source = { - :git => 'https://github.com/firebase/firebase-ios-sdk.git', - :tag => 'CocoaPods-' + s.version.to_s - } - s.social_media_url = 'https://twitter.com/Firebase' - s.ios.deployment_target = '10.0' - s.osx.deployment_target = '10.13' - s.tvos.deployment_target = '12.0' - s.watchos.deployment_target = '6.0' - - base_dir = "AppCheckCore/Interop/" - - s.source_files = base_dir + '**/*.[mh]' - s.public_header_files = base_dir + 'Public/AppCheckCoreInterop/*.h' -end