diff --git a/Apple/.DS_Store b/Apple/.DS_Store new file mode 100644 index 0000000..6bf97d7 Binary files /dev/null and b/Apple/.DS_Store differ diff --git a/Apple/App/App-iOS.entitlements b/Apple/App/App-iOS.entitlements index d9849a8..02ee960 100644 --- a/Apple/App/App-iOS.entitlements +++ b/Apple/App/App-iOS.entitlements @@ -2,6 +2,10 @@ + com.apple.developer.networking.networkextension + + packet-tunnel-provider + com.apple.security.application-groups $(APP_GROUP_IDENTIFIER) diff --git a/Apple/App/App-macOS.entitlements b/Apple/App/App-macOS.entitlements index d9849a8..7395b5c 100644 --- a/Apple/App/App-macOS.entitlements +++ b/Apple/App/App-macOS.entitlements @@ -2,9 +2,14 @@ + com.apple.developer.networking.networkextension + + packet-tunnel-provider + com.apple.security.application-groups $(APP_GROUP_IDENTIFIER) + group.ThomasStubblefield.Unifriend.onesignal diff --git a/Apple/App/AppDelegate.swift b/Apple/App/AppDelegate.swift new file mode 100644 index 0000000..25c9baf --- /dev/null +++ b/Apple/App/AppDelegate.swift @@ -0,0 +1,14 @@ +#if os(macOS) +import AppKit +import FluidMenuBarExtra + +class AppDelegate: NSObject, NSApplicationDelegate { + private var menuBarExtra: FluidMenuBarExtra? + + func applicationDidFinishLaunching(_ notification: Notification) { + self.menuBarExtra = FluidMenuBarExtra(title: "Burrow", systemImage: "network.badge.shield.half.filled") { + ContentView() + } + } +} +#endif diff --git a/Apple/App/Assets.xcassets/hackClubLogo.imageset/Contents.json b/Apple/App/Assets.xcassets/hackClubLogo.imageset/Contents.json new file mode 100644 index 0000000..76da2cb --- /dev/null +++ b/Apple/App/Assets.xcassets/hackClubLogo.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "hackClubLogo.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Apple/App/Assets.xcassets/hackClubLogo.imageset/hackClubLogo.png b/Apple/App/Assets.xcassets/hackClubLogo.imageset/hackClubLogo.png new file mode 100644 index 0000000..6823ccf Binary files /dev/null and b/Apple/App/Assets.xcassets/hackClubLogo.imageset/hackClubLogo.png differ diff --git a/Apple/App/BurrowApp.swift b/Apple/App/BurrowApp.swift index b145dea..fc05084 100644 --- a/Apple/App/BurrowApp.swift +++ b/Apple/App/BurrowApp.swift @@ -1,10 +1,34 @@ +// +// burrow_barApp.swift +// burrow-bar +// +// Created by Thomas Stubblefield on 4/19/23. +// + import SwiftUI +import NetworkExtension @main -struct BurrowApp: App { +struct burrowBarApp: App { + #if os(macOS) + @NSApplicationDelegateAdaptor private var appDelegate: AppDelegate + #endif + var body: some Scene { WindowGroup { - ContentView() + PermissionView() + } + } +} + +struct PermissionView: View { + @ObservedObject + var configuration = NetworkConfiguration() + + + var body: some View { + VStack { + Text(verbatim: "Status is \(configuration.status)") } } } diff --git a/Apple/App/ContentView.swift b/Apple/App/ContentView.swift index f54deab..aa92046 100644 --- a/Apple/App/ContentView.swift +++ b/Apple/App/ContentView.swift @@ -1,14 +1,68 @@ import SwiftUI struct ContentView: View { + + @ObservedObject var viewModel = NetworkConfiguration() + var body: some View { - VStack { - Image(systemName: "globe") - .imageScale(.large) - .foregroundColor(.accentColor) - Text("Hello, world!") + VStack(alignment: .leading) { + + HStack { + Text(verbatim: "Networks \(viewModel.model.status)") + .font(.title3) + Spacer() + Image(systemName: "badge.plus.radiowaves.forward") + .symbolRenderingMode(.palette) + .foregroundStyle(.blue, .black) + .opacity(0.4) + .imageScale(.large) } + Divider() + VStack(alignment: .leading) { + Text("Burrows") + .padding(.top, 2) + .font(.subheadline.weight(.bold)) + HStack { + if (viewModel.status == .unknown) { + + + Image("hackClubLogo") + .resizable() + .frame(width: 32, height: 32) + .cornerRadius(100).onTapGesture { + viewModel.connectToBurrow() + print(viewModel.status) + } + + } else if (viewModel.status == .loading) { + ZStack { + Image("hackClubLogo") + .resizable() + .frame(width: 32, height: 32) + .cornerRadius(100) + .overlay(Color.white.opacity(0.6).cornerRadius(100)) + + ProgressView() + .progressViewStyle(CircularProgressViewStyle()) + .scaleEffect(0.6) + } + } + VStack(alignment: .leading) { + + Text("Hack Club Network") + .fontWeight(.medium) + + + Text("􁠲 Recently Validated Certificate") + .font(.caption2) + .foregroundColor(.blue) + }.onTapGesture { + print(true) + } + } + } + } - .padding() + .padding() } } diff --git a/Apple/App/Model.swift b/Apple/App/Model.swift new file mode 100644 index 0000000..68d63fd --- /dev/null +++ b/Apple/App/Model.swift @@ -0,0 +1,42 @@ +// +// MemoryGame.swift +// Memorize +// +// Created by Thomas Stubblefield on 3/12/23. +// + +import Foundation + +struct Model { + + var status: Status = .unknown + + mutating func connectToBurrow() { + print("let's get this working") + status = .valid + print(status) + } +} + +enum Status: CustomStringConvertible { + case unknown + case blank + case valid + case error + case loading + + var description: String { + switch self { + case .unknown: + return "Unknown" + case .blank: + return "Blank" + case .valid: + return "Valid" + case .loading: + return "Loading" + default: + return "Default" + } + } +} diff --git a/Apple/App/NetworkConfiguration.swift b/Apple/App/NetworkConfiguration.swift new file mode 100644 index 0000000..89bc601 --- /dev/null +++ b/Apple/App/NetworkConfiguration.swift @@ -0,0 +1,87 @@ +import SwiftUI +import NetworkExtension + +@MainActor +class NetworkConfiguration: ObservableObject { + func connectToBurrow() { + objectWillChange.send() + model.connectToBurrow() + } + + @Published var model = Model() + + @Published + var status: Status = .unknown + + init() { + update() + + + } + + func connectToNetwork() { + print(self.status) + self.status = .loading + print(self.status) + + DispatchQueue.main.asyncAfter(deadline: .now() + 3) { + let random = Int.random(in: 0...1) + if random == 0 { + self.status = .valid + print(self.status) + + } else { + self.status = .error + print(self.status) + + } + } + } + + func update() { + Task { + do { + let configurations = try await NETunnelProviderManager.loadAll() + + await MainActor.run { + self.status = configurations.isEmpty ? .blank : .valid + print(self.status) + self.objectWillChange.send() + } + } catch { + await MainActor.run { + self.status = .error + self.objectWillChange.send() + + } + } + } + } + + func request() { + let configuration = NETunnelProviderProtocol() + configuration.providerBundleIdentifier = "" + configuration.serverAddress = "Hack Club" + + let manager = NETunnelProviderManager() + manager.protocolConfiguration = configuration + manager.localizedDescription = "Hack Club Burrow" + manager.saveToPreferences { error in + print(error) + } + } +} + +extension NETunnelProviderManager { + static func loadAll() async throws -> [NETunnelProviderManager] { + try await withUnsafeThrowingContinuation { continuation in + NETunnelProviderManager.loadAllFromPreferences { managers, error in + if let error = error { + continuation.resume(throwing: error) + } else { + continuation.resume(returning: managers ?? []) + } + } + } + } +} diff --git a/Apple/Burrow.xcodeproj/project.pbxproj b/Apple/Burrow.xcodeproj/project.pbxproj index fa4009a..be8f359 100644 --- a/Apple/Burrow.xcodeproj/project.pbxproj +++ b/Apple/Burrow.xcodeproj/project.pbxproj @@ -7,6 +7,10 @@ objects = { /* Begin PBXBuildFile section */ + 43E50D6D29FA050600BD2280 /* FluidMenuBarExtra in Frameworks */ = {isa = PBXBuildFile; platformFilters = (macos, ); productRef = 43E50D6C29FA050600BD2280 /* FluidMenuBarExtra */; }; + 43EBDB2B29FD7557005D8CFF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43EBDB2A29FD754A005D8CFF /* AppDelegate.swift */; }; + 43EBDB2D29FD759E005D8CFF /* NetworkConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43EBDB2C29FD759E005D8CFF /* NetworkConfiguration.swift */; }; + 43EBDB2F29FDE85F005D8CFF /* Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43EBDB2E29FDE85F005D8CFF /* Model.swift */; }; D020F65829E4A697002790F6 /* PacketTunnelProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = D020F65729E4A697002790F6 /* PacketTunnelProvider.swift */; }; D020F65D29E4A697002790F6 /* BurrowNetworkExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = D020F65329E4A697002790F6 /* BurrowNetworkExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; D05B9F7629E39EEC008CB1F9 /* BurrowApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = D05B9F7529E39EEC008CB1F9 /* BurrowApp.swift */; }; @@ -39,6 +43,9 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 43EBDB2A29FD754A005D8CFF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 43EBDB2C29FD759E005D8CFF /* NetworkConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkConfiguration.swift; sourceTree = ""; }; + 43EBDB2E29FDE85F005D8CFF /* Model.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Model.swift; sourceTree = ""; }; D020F63D29E4A1FF002790F6 /* Identity.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Identity.xcconfig; sourceTree = ""; }; D020F64029E4A1FF002790F6 /* Compiler.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Compiler.xcconfig; sourceTree = ""; }; D020F64229E4A1FF002790F6 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -71,6 +78,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 43E50D6D29FA050600BD2280 /* FluidMenuBarExtra in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -124,7 +132,10 @@ isa = PBXGroup; children = ( D05B9F7529E39EEC008CB1F9 /* BurrowApp.swift */, + 43EBDB2A29FD754A005D8CFF /* AppDelegate.swift */, D05B9F7729E39EEC008CB1F9 /* ContentView.swift */, + 43EBDB2C29FD759E005D8CFF /* NetworkConfiguration.swift */, + 43EBDB2E29FDE85F005D8CFF /* Model.swift */, D05B9F7929E39EED008CB1F9 /* Assets.xcassets */, D020F66829E4AA74002790F6 /* App-iOS.entitlements */, D020F66929E4AA74002790F6 /* App-macOS.entitlements */, @@ -168,6 +179,9 @@ D020F65C29E4A697002790F6 /* PBXTargetDependency */, ); name = Burrow; + packageProductDependencies = ( + 43E50D6C29FA050600BD2280 /* FluidMenuBarExtra */, + ); productName = Burrow; productReference = D05B9F7229E39EEC008CB1F9 /* Burrow.app */; productType = "com.apple.product-type.application"; @@ -199,6 +213,9 @@ Base, ); mainGroup = D05B9F6929E39EEC008CB1F9; + packageReferences = ( + 43E50D6B29FA050600BD2280 /* XCRemoteSwiftPackageReference "fluid-menu-bar-extra" */, + ); productRefGroup = D05B9F7329E39EEC008CB1F9 /* Products */; projectDirPath = ""; projectRoot = ""; @@ -240,8 +257,11 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 43EBDB2F29FDE85F005D8CFF /* Model.swift in Sources */, + 43EBDB2B29FD7557005D8CFF /* AppDelegate.swift in Sources */, D05B9F7829E39EEC008CB1F9 /* ContentView.swift in Sources */, D05B9F7629E39EEC008CB1F9 /* BurrowApp.swift in Sources */, + 43EBDB2D29FD759E005D8CFF /* NetworkConfiguration.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -260,6 +280,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = D020F66229E4A6E5002790F6 /* NetworkExtension.xcconfig */; buildSettings = { + DEVELOPMENT_TEAM = 2H4LMN3ZLG; }; name = Debug; }; @@ -267,6 +288,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = D020F66229E4A6E5002790F6 /* NetworkExtension.xcconfig */; buildSettings = { + DEVELOPMENT_TEAM = 2H4LMN3ZLG; }; name = Release; }; @@ -288,6 +310,8 @@ isa = XCBuildConfiguration; baseConfigurationReference = D020F64929E4A34B002790F6 /* Burrow.xcconfig */; buildSettings = { + DEVELOPMENT_TEAM = 2H4LMN3ZLG; + MACOSX_DEPLOYMENT_TARGET = 13.0; }; name = Debug; }; @@ -295,6 +319,8 @@ isa = XCBuildConfiguration; baseConfigurationReference = D020F64929E4A34B002790F6 /* Burrow.xcconfig */; buildSettings = { + DEVELOPMENT_TEAM = 2H4LMN3ZLG; + MACOSX_DEPLOYMENT_TARGET = 13.0; }; name = Release; }; @@ -329,6 +355,25 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + 43E50D6B29FA050600BD2280 /* XCRemoteSwiftPackageReference "fluid-menu-bar-extra" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/lfroms/fluid-menu-bar-extra.git"; + requirement = { + branch = main; + kind = branch; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 43E50D6C29FA050600BD2280 /* FluidMenuBarExtra */ = { + isa = XCSwiftPackageProductDependency; + package = 43E50D6B29FA050600BD2280 /* XCRemoteSwiftPackageReference "fluid-menu-bar-extra" */; + productName = FluidMenuBarExtra; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = D05B9F6A29E39EEC008CB1F9 /* Project object */; } diff --git a/Apple/Burrow.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Apple/Burrow.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000..569a50e --- /dev/null +++ b/Apple/Burrow.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,14 @@ +{ + "pins" : [ + { + "identity" : "fluid-menu-bar-extra", + "kind" : "remoteSourceControl", + "location" : "https://github.com/lfroms/fluid-menu-bar-extra.git", + "state" : { + "branch" : "main", + "revision" : "b8d41bc1c2609c3943c47d00fb539de38f90b817" + } + } + ], + "version" : 2 +} diff --git a/Apple/Configuration/Identity.xcconfig b/Apple/Configuration/Identity.xcconfig index e4ef90e..6ff2392 100644 --- a/Apple/Configuration/Identity.xcconfig +++ b/Apple/Configuration/Identity.xcconfig @@ -1,2 +1,2 @@ -DEVELOPMENT_TEAM = 87PW93R2ZR -APP_BUNDLE_IDENTIFIER = com.hackclub.burrow +DEVELOPMENT_TEAM = 2H4LMN3ZLG +APP_BUNDLE_IDENTIFIER = com.ThomasStubblefield.burrow