Skip to content

Commit

Permalink
Adopt function improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
federicocappelli committed Dec 24, 2024
1 parent 771d444 commit dfc9582
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Sources/NetworkProtection/PacketTunnelProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -603,13 +603,13 @@ open class PacketTunnelProvider: NEPacketTunnelProvider {
Logger.networkProtection.log("Loading token \(options.tokenContainer.description, privacy: .public)")
switch options.tokenContainer {
case .set(let newTokenContainer):
try await tokenProvider.adopt(tokenContainer: newTokenContainer)
tokenProvider.adopt(tokenContainer: newTokenContainer)
// Important: Here we force the token refresh in order to immediately branch the system extension token from the main app one.
// See discussion https://app.asana.com/0/1199230911884351/1208785842165508/f
try await tokenProvider.getTokenContainer(policy: .localForceRefresh)
case .useExisting:
do {
try await tokenProvider.getTokenContainer(policy: .local)
try await tokenProvider.getTokenContainer(policy: .localValid)
} catch {
throw TunnelError.startingTunnelWithoutAuthToken
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Subscription/Managers/SubscriptionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public protocol SubscriptionTokenProvider {
func exchange(tokenV1: String) async throws -> TokenContainer

/// Used only from the Mac Packet Tunnel Provider when a token is received during configuration
func adopt(tokenContainer: TokenContainer) async throws
func adopt(tokenContainer: TokenContainer)

/// Remove the stored token container
func removeTokenContainer()
Expand Down Expand Up @@ -357,7 +357,7 @@ public final class DefaultSubscriptionManager: SubscriptionManager {
return tokenContainer
}

public func adopt(tokenContainer: TokenContainer) async throws {
public func adopt(tokenContainer: TokenContainer) {
oAuthClient.currentTokenContainer = tokenContainer
}

Expand Down

0 comments on commit dfc9582

Please sign in to comment.