Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
uses: actions/checkout@v4
with:
repository: qtmleap/Mudmouth
ref: 698d5bcb25245a26a3be925c34ded8a4c8a2ff6a
ref: 5c97774f645023b22366db5abe86797915da2d33
path: Mudmouth
persist-credentials: false

Expand Down
16 changes: 8 additions & 8 deletions Interceptor.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@
CODE_SIGN_ENTITLEMENTS = Interceptor/Interceptor.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 29;
CURRENT_PROJECT_VERSION = 30;
DEVELOPMENT_TEAM = 5Q94QJ7G98;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand Down Expand Up @@ -612,7 +612,7 @@
CODE_SIGN_ENTITLEMENTS = Interceptor/Interceptor.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 29;
CURRENT_PROJECT_VERSION = 30;
DEVELOPMENT_TEAM = 5Q94QJ7G98;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand Down Expand Up @@ -647,7 +647,7 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 29;
CURRENT_PROJECT_VERSION = 30;
DEVELOPMENT_TEAM = 5Q94QJ7G98;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 18.5;
Expand All @@ -666,7 +666,7 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 29;
CURRENT_PROJECT_VERSION = 30;
DEVELOPMENT_TEAM = 5Q94QJ7G98;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 18.5;
Expand All @@ -684,7 +684,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 29;
CURRENT_PROJECT_VERSION = 30;
DEVELOPMENT_TEAM = 5Q94QJ7G98;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
Expand All @@ -701,7 +701,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 29;
CURRENT_PROJECT_VERSION = 30;
DEVELOPMENT_TEAM = 5Q94QJ7G98;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
Expand All @@ -720,7 +720,7 @@
CODE_SIGN_ENTITLEMENTS = PacketTunnel/PacketTunnel.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 29;
CURRENT_PROJECT_VERSION = 30;
DEVELOPMENT_TEAM = 5Q94QJ7G98;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = PacketTunnel/Info.plist;
Expand Down Expand Up @@ -752,7 +752,7 @@
CODE_SIGN_ENTITLEMENTS = PacketTunnel/PacketTunnel.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 29;
CURRENT_PROJECT_VERSION = 30;
DEVELOPMENT_TEAM = 5Q94QJ7G98;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = PacketTunnel/Info.plist;
Expand Down
8 changes: 8 additions & 0 deletions Interceptor/Classes/Tuberose.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ public final class Tuberose: ObservableObject {
mudmouth.stopVPNTunnel()
}

func withdrawCaptureConsent() {
CaptureAuthorization.revoke()
activateOnForeground = false
stopVPNTunnel()
UNUserNotificationCenter.current().removeAllPendingNotificationRequests()
UNUserNotificationCenter.current().removeAllDeliveredNotifications()
}

func setToken(_ value: UNNotificationResponse) throws {
try CaptureAuthorization.requireConsent()
guard let rawID = value.notification.request.content.userInfo["recordID"] as? String,
Expand Down
50 changes: 34 additions & 16 deletions Interceptor/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,42 @@ import SwiftyLogger

struct ContentView: View {
@Environment(\.isFirstLaunch) private var isFirstLaunch: Binding<Bool>
@AppStorage("CaptureConsentDecided") private var consentDecided = false
@State private var showConsent = false
@EnvironmentObject private var client: Tuberose
@Environment(\.scenePhase) private var scenePhase
@AppStorage(CaptureAuthorization.key, store: CaptureAuthorization.defaults) private var consentVersion = 0

private var requiresConsent: Bool { consentVersion != CaptureAuthorization.version }

var body: some View {
Group {
if requiresConsent {
// Keep history, settings and their presentations unavailable until agreement.
Color(.systemBackground).ignoresSafeArea()
} else {
mainTabs
}
}
.onAppear { stopCaptureIfUnauthorized() }
.onChange(of: consentVersion) { stopCaptureIfUnauthorized() }
.onChange(of: scenePhase) {
if scenePhase == .active {
consentVersion = CaptureAuthorization.defaults.integer(forKey: CaptureAuthorization.key)
stopCaptureIfUnauthorized()
}
}
.fullScreenCover(isPresented: Binding(get: { requiresConsent }, set: { _ in })) {
NavigationStack {
DataUseConsentView { isFirstLaunch.wrappedValue = false }
}
.interactiveDismissDisabled()
}
}

private func stopCaptureIfUnauthorized() {
if !CaptureAuthorization.isGranted { client.stopVPNTunnel() }
}

private var mainTabs: some View {
TabView(content: {
NavigationView(content: {
HomeView()
Expand Down Expand Up @@ -50,20 +82,6 @@ struct ContentView: View {
tabView.tabBar.backgroundColor = .systemBackground
tabView.tabBar.isTranslucent = true
})
.onAppear {
let version = CaptureAuthorization.defaults.integer(forKey: CaptureAuthorization.key)
showConsent = !consentDecided || (version != 0 && version != CaptureAuthorization.version)
if !CaptureAuthorization.isGranted { Tuberose.default.stopVPNTunnel() }
}
.fullScreenCover(isPresented: $showConsent) {
NavigationStack {
DataUseConsentView { _ in
consentDecided = true
isFirstLaunch.wrappedValue = false
showConsent = false
}
}.interactiveDismissDisabled()
}
}
}

Expand Down
Loading
Loading