Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ let package = Package(
dependencies: [
.product(name: "GRPC", package: "grpc-swift"),
.product(name: "FirebaseCore", package: "firebase-ios-sdk"),
// TODO: Investigate switching Auth and AppCheck to interop.
// TODO: Investigate switching Auth to interop.
.product(name: "FirebaseAuth", package: "firebase-ios-sdk"),
.product(name: "FirebaseAppCheck", package: "firebase-ios-sdk"),
.product(name: "GULEnvironment", package: "GoogleUtilities"),
],
path: "Sources"
Expand Down
1 change: 0 additions & 1 deletion Sources/DataConnect.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import Foundation

@preconcurrency import FirebaseAppCheck
@preconcurrency import FirebaseAuth
@preconcurrency import FirebaseCore

Expand Down
23 changes: 9 additions & 14 deletions Sources/Internal/GrpcClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@

import Foundation

@preconcurrency import FirebaseAppCheck
@preconcurrency import FirebaseAppCheckInterop
@preconcurrency import FirebaseAuth
import FirebaseCore
@preconcurrency import FirebaseCoreExtension
import GRPC
import Logging
import NIOCore
Expand Down Expand Up @@ -47,7 +48,7 @@ actor GrpcClient: CustomStringConvertible {

private let auth: Auth

private let appCheck: AppCheck?
private let appCheck: AppCheckInterop?

private let callerSDKType: CallerSDKType

Expand Down Expand Up @@ -108,7 +109,7 @@ actor GrpcClient: CustomStringConvertible {
serverSettings = settings
self.connectorConfig = connectorConfig
auth = Auth.auth(app: app)
appCheck = AppCheck.appCheck(app: app)
appCheck = ComponentType<AppCheckInterop>.instance(for: AppCheckInterop.self, in: app.container)
self.callerSDKType = callerSDKType

connectorName =
Expand Down Expand Up @@ -258,17 +259,11 @@ actor GrpcClient: CustomStringConvertible {
}

// Add AppCheck token if available
do {
if let token = try await appCheck?.token(forcingRefresh: false) {
headers.add(name: RequestHeaders.appCheckHeader, value: token.token)
DataConnectLogger.debug("App Check token added.")
} else {
DataConnectLogger.debug("App Check token unavailable. Not adding App Check header.")
}
} catch {
DataConnectLogger.debug(
"Cannot get App Check token successfully due to: \(error). Not adding App Check header."
)
if let token = await appCheck?.getToken(forcingRefresh: false) {
headers.add(name: RequestHeaders.appCheckHeader, value: token.token)
DataConnectLogger.debug("App Check token added.")
} else {
DataConnectLogger.debug("App Check token unavailable. Not adding App Check header.")
}

var options = CallOptions(customMetadata: headers)
Expand Down
Loading