commit cddc684f545129d59d18ba1e69429ba7f000f1cf Author: James Magahern Date: Wed Jul 22 19:29:38 2020 -0700 Initial commit Able to actually block scripts using a plugin, have XPC set up between plugin and host process. Limited UI support diff --git a/SBrowser.xcodeproj/project.pbxproj b/SBrowser.xcodeproj/project.pbxproj new file mode 100644 index 0000000..f36b749 --- /dev/null +++ b/SBrowser.xcodeproj/project.pbxproj @@ -0,0 +1,545 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 1ADFF46024C7DE53006DC7AE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ADFF45F24C7DE53006DC7AE /* AppDelegate.swift */; }; + 1ADFF46224C7DE53006DC7AE /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ADFF46124C7DE53006DC7AE /* SceneDelegate.swift */; }; + 1ADFF46924C7DE54006DC7AE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1ADFF46824C7DE54006DC7AE /* Assets.xcassets */; }; + 1ADFF46C24C7DE54006DC7AE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1ADFF46A24C7DE54006DC7AE /* LaunchScreen.storyboard */; }; + 1ADFF47424C7DE9C006DC7AE /* BrowserViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ADFF47324C7DE9C006DC7AE /* BrowserViewController.swift */; }; + 1ADFF47924C7DFF8006DC7AE /* BrowserView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ADFF47824C7DFF8006DC7AE /* BrowserView.swift */; }; + 1ADFF48424C8C12F006DC7AE /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1ADFF48324C8C12F006DC7AE /* Foundation.framework */; }; + 1ADFF48D24C8C176006DC7AE /* SBRProcessBundleBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 1ADFF48C24C8C176006DC7AE /* SBRProcessBundleBridge.m */; }; + 1ADFF4A724C8C271006DC7AE /* SBrowserProcessBundle.bundle in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 1ADFF48124C8C12F006DC7AE /* SBrowserProcessBundle.bundle */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 1ADFF4AA24C8D477006DC7AE /* SBRProcessPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 1ADFF4A924C8D477006DC7AE /* SBRProcessPlugin.m */; }; + 1ADFF4AE24C8ED32006DC7AE /* ResourcePolicyManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ADFF4AD24C8ED32006DC7AE /* ResourcePolicyManager.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 1ADFF48E24C8C230006DC7AE /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 1ADFF45424C7DE53006DC7AE /* Project object */; + proxyType = 1; + remoteGlobalIDString = 1ADFF48024C8C12F006DC7AE; + remoteInfo = SBrowserProcessBundle; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 1ADFF4A124C8C25B006DC7AE /* Embed App Extensions */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 13; + files = ( + 1ADFF4A724C8C271006DC7AE /* SBrowserProcessBundle.bundle in Embed App Extensions */, + ); + name = "Embed App Extensions"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1ADFF45C24C7DE53006DC7AE /* SBrowser.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SBrowser.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 1ADFF45F24C7DE53006DC7AE /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 1ADFF46124C7DE53006DC7AE /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + 1ADFF46824C7DE54006DC7AE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 1ADFF46B24C7DE54006DC7AE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 1ADFF46D24C7DE54006DC7AE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 1ADFF47324C7DE9C006DC7AE /* BrowserViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BrowserViewController.swift; sourceTree = ""; }; + 1ADFF47524C7DF20006DC7AE /* SBrowser.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = SBrowser.entitlements; sourceTree = ""; }; + 1ADFF47824C7DFF8006DC7AE /* BrowserView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BrowserView.swift; sourceTree = ""; }; + 1ADFF48124C8C12F006DC7AE /* SBrowserProcessBundle.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SBrowserProcessBundle.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; + 1ADFF48324C8C12F006DC7AE /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 1ADFF48624C8C12F006DC7AE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 1ADFF48A24C8C176006DC7AE /* SBrowser-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SBrowser-Bridging-Header.h"; sourceTree = ""; }; + 1ADFF48B24C8C176006DC7AE /* SBRProcessBundleBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SBRProcessBundleBridge.h; sourceTree = ""; }; + 1ADFF48C24C8C176006DC7AE /* SBRProcessBundleBridge.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SBRProcessBundleBridge.m; sourceTree = ""; }; + 1ADFF4A824C8D476006DC7AE /* SBRProcessPlugin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SBRProcessPlugin.h; sourceTree = ""; }; + 1ADFF4A924C8D477006DC7AE /* SBRProcessPlugin.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SBRProcessPlugin.m; sourceTree = ""; }; + 1ADFF4AB24C8DF62006DC7AE /* SBRWebProcessDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SBRWebProcessDelegate.h; sourceTree = ""; }; + 1ADFF4AC24C8DFEE006DC7AE /* SBRWebProcessProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SBRWebProcessProxy.h; sourceTree = ""; }; + 1ADFF4AD24C8ED32006DC7AE /* ResourcePolicyManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResourcePolicyManager.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 1ADFF45924C7DE53006DC7AE /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 1ADFF47E24C8C12F006DC7AE /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 1ADFF48424C8C12F006DC7AE /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 1ADFF45324C7DE53006DC7AE = { + isa = PBXGroup; + children = ( + 1ADFF45E24C7DE53006DC7AE /* SBrowser */, + 1ADFF48524C8C12F006DC7AE /* SBrowserProcessBundle */, + 1ADFF48224C8C12F006DC7AE /* Frameworks */, + 1ADFF45D24C7DE53006DC7AE /* Products */, + ); + sourceTree = ""; + }; + 1ADFF45D24C7DE53006DC7AE /* Products */ = { + isa = PBXGroup; + children = ( + 1ADFF45C24C7DE53006DC7AE /* SBrowser.app */, + 1ADFF48124C8C12F006DC7AE /* SBrowserProcessBundle.bundle */, + ); + name = Products; + sourceTree = ""; + }; + 1ADFF45E24C7DE53006DC7AE /* SBrowser */ = { + isa = PBXGroup; + children = ( + 1ADFF45F24C7DE53006DC7AE /* AppDelegate.swift */, + 1ADFF46124C7DE53006DC7AE /* SceneDelegate.swift */, + 1ADFF47A24C7E176006DC7AE /* Backend */, + 1ADFF47724C7DFE8006DC7AE /* Browser View */, + 1ADFF47624C7DF7F006DC7AE /* Supporting Files */, + ); + path = SBrowser; + sourceTree = ""; + }; + 1ADFF47624C7DF7F006DC7AE /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 1ADFF48A24C8C176006DC7AE /* SBrowser-Bridging-Header.h */, + 1ADFF47524C7DF20006DC7AE /* SBrowser.entitlements */, + 1ADFF46824C7DE54006DC7AE /* Assets.xcassets */, + 1ADFF46A24C7DE54006DC7AE /* LaunchScreen.storyboard */, + 1ADFF46D24C7DE54006DC7AE /* Info.plist */, + ); + path = "Supporting Files"; + sourceTree = ""; + }; + 1ADFF47724C7DFE8006DC7AE /* Browser View */ = { + isa = PBXGroup; + children = ( + 1ADFF47324C7DE9C006DC7AE /* BrowserViewController.swift */, + 1ADFF47824C7DFF8006DC7AE /* BrowserView.swift */, + 1ADFF48B24C8C176006DC7AE /* SBRProcessBundleBridge.h */, + 1ADFF48C24C8C176006DC7AE /* SBRProcessBundleBridge.m */, + ); + path = "Browser View"; + sourceTree = ""; + }; + 1ADFF47A24C7E176006DC7AE /* Backend */ = { + isa = PBXGroup; + children = ( + 1ADFF4AD24C8ED32006DC7AE /* ResourcePolicyManager.swift */, + ); + path = Backend; + sourceTree = ""; + }; + 1ADFF48224C8C12F006DC7AE /* Frameworks */ = { + isa = PBXGroup; + children = ( + 1ADFF48324C8C12F006DC7AE /* Foundation.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 1ADFF48524C8C12F006DC7AE /* SBrowserProcessBundle */ = { + isa = PBXGroup; + children = ( + 1ADFF48624C8C12F006DC7AE /* Info.plist */, + 1ADFF4AB24C8DF62006DC7AE /* SBRWebProcessDelegate.h */, + 1ADFF4AC24C8DFEE006DC7AE /* SBRWebProcessProxy.h */, + 1ADFF4A824C8D476006DC7AE /* SBRProcessPlugin.h */, + 1ADFF4A924C8D477006DC7AE /* SBRProcessPlugin.m */, + ); + path = SBrowserProcessBundle; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 1ADFF45B24C7DE53006DC7AE /* SBrowser */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1ADFF47024C7DE54006DC7AE /* Build configuration list for PBXNativeTarget "SBrowser" */; + buildPhases = ( + 1ADFF45824C7DE53006DC7AE /* Sources */, + 1ADFF45924C7DE53006DC7AE /* Frameworks */, + 1ADFF45A24C7DE53006DC7AE /* Resources */, + 1ADFF4A124C8C25B006DC7AE /* Embed App Extensions */, + ); + buildRules = ( + ); + dependencies = ( + 1ADFF48F24C8C230006DC7AE /* PBXTargetDependency */, + ); + name = SBrowser; + productName = SBrowser; + productReference = 1ADFF45C24C7DE53006DC7AE /* SBrowser.app */; + productType = "com.apple.product-type.application"; + }; + 1ADFF48024C8C12F006DC7AE /* SBrowserProcessBundle */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1ADFF48724C8C12F006DC7AE /* Build configuration list for PBXNativeTarget "SBrowserProcessBundle" */; + buildPhases = ( + 1ADFF47D24C8C12F006DC7AE /* Sources */, + 1ADFF47E24C8C12F006DC7AE /* Frameworks */, + 1ADFF47F24C8C12F006DC7AE /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = SBrowserProcessBundle; + productName = SBrowserProcessBundle; + productReference = 1ADFF48124C8C12F006DC7AE /* SBrowserProcessBundle.bundle */; + productType = "com.apple.product-type.bundle"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 1ADFF45424C7DE53006DC7AE /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1200; + LastUpgradeCheck = 1200; + TargetAttributes = { + 1ADFF45B24C7DE53006DC7AE = { + CreatedOnToolsVersion = 12.0; + LastSwiftMigration = 1200; + }; + 1ADFF48024C8C12F006DC7AE = { + CreatedOnToolsVersion = 12.0; + }; + }; + }; + buildConfigurationList = 1ADFF45724C7DE53006DC7AE /* Build configuration list for PBXProject "SBrowser" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 1ADFF45324C7DE53006DC7AE; + productRefGroup = 1ADFF45D24C7DE53006DC7AE /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 1ADFF45B24C7DE53006DC7AE /* SBrowser */, + 1ADFF48024C8C12F006DC7AE /* SBrowserProcessBundle */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 1ADFF45A24C7DE53006DC7AE /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1ADFF46C24C7DE54006DC7AE /* LaunchScreen.storyboard in Resources */, + 1ADFF46924C7DE54006DC7AE /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 1ADFF47F24C8C12F006DC7AE /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 1ADFF45824C7DE53006DC7AE /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1ADFF46024C7DE53006DC7AE /* AppDelegate.swift in Sources */, + 1ADFF4AE24C8ED32006DC7AE /* ResourcePolicyManager.swift in Sources */, + 1ADFF47424C7DE9C006DC7AE /* BrowserViewController.swift in Sources */, + 1ADFF48D24C8C176006DC7AE /* SBRProcessBundleBridge.m in Sources */, + 1ADFF46224C7DE53006DC7AE /* SceneDelegate.swift in Sources */, + 1ADFF47924C7DFF8006DC7AE /* BrowserView.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 1ADFF47D24C8C12F006DC7AE /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1ADFF4AA24C8D477006DC7AE /* SBRProcessPlugin.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 1ADFF48F24C8C230006DC7AE /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 1ADFF48024C8C12F006DC7AE /* SBrowserProcessBundle */; + targetProxy = 1ADFF48E24C8C230006DC7AE /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 1ADFF46A24C7DE54006DC7AE /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 1ADFF46B24C7DE54006DC7AE /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 1ADFF46E24C7DE54006DC7AE /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos.internal; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 1ADFF46F24C7DE54006DC7AE /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos.internal; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 1ADFF47124C7DE54006DC7AE /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = "SBrowser/Supporting Files/SBrowser.entitlements"; + CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = ""; + INFOPLIST_FILE = "SBrowser/Supporting Files/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 10.15; + PRODUCT_BUNDLE_IDENTIFIER = net.buzzert.SBrowser; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SUPPORTS_MACCATALYST = NO; + SWIFT_OBJC_BRIDGING_HEADER = "SBrowser/Supporting Files/SBrowser-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 1ADFF47224C7DE54006DC7AE /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = "SBrowser/Supporting Files/SBrowser.entitlements"; + CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = ""; + INFOPLIST_FILE = "SBrowser/Supporting Files/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 10.15; + PRODUCT_BUNDLE_IDENTIFIER = net.buzzert.SBrowser; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SUPPORTS_MACCATALYST = NO; + SWIFT_OBJC_BRIDGING_HEADER = "SBrowser/Supporting Files/SBrowser-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + 1ADFF48824C8C12F006DC7AE /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + INFOPLIST_FILE = SBrowserProcessBundle/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles"; + PRODUCT_BUNDLE_IDENTIFIER = net.buzzert.SBrowserProcessBundle; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos.internal; + STRIP_INSTALLED_PRODUCT = NO; + SUPPORTS_MACCATALYST = NO; + TARGETED_DEVICE_FAMILY = "1,2"; + WRAPPER_EXTENSION = bundle; + }; + name = Debug; + }; + 1ADFF48924C8C12F006DC7AE /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + INFOPLIST_FILE = SBrowserProcessBundle/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles"; + PRODUCT_BUNDLE_IDENTIFIER = net.buzzert.SBrowserProcessBundle; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos.internal; + SUPPORTS_MACCATALYST = NO; + TARGETED_DEVICE_FAMILY = "1,2"; + WRAPPER_EXTENSION = bundle; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1ADFF45724C7DE53006DC7AE /* Build configuration list for PBXProject "SBrowser" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1ADFF46E24C7DE54006DC7AE /* Debug */, + 1ADFF46F24C7DE54006DC7AE /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1ADFF47024C7DE54006DC7AE /* Build configuration list for PBXNativeTarget "SBrowser" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1ADFF47124C7DE54006DC7AE /* Debug */, + 1ADFF47224C7DE54006DC7AE /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1ADFF48724C8C12F006DC7AE /* Build configuration list for PBXNativeTarget "SBrowserProcessBundle" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1ADFF48824C8C12F006DC7AE /* Debug */, + 1ADFF48924C8C12F006DC7AE /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 1ADFF45424C7DE53006DC7AE /* Project object */; +} diff --git a/SBrowser.xcodeproj/xcshareddata/xcschemes/BSExtension.xcscheme b/SBrowser.xcodeproj/xcshareddata/xcschemes/BSExtension.xcscheme new file mode 100644 index 0000000..80eb9fc --- /dev/null +++ b/SBrowser.xcodeproj/xcshareddata/xcschemes/BSExtension.xcscheme @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SBrowser.xcodeproj/xcshareddata/xcschemes/SBrowser.xcscheme b/SBrowser.xcodeproj/xcshareddata/xcschemes/SBrowser.xcscheme new file mode 100644 index 0000000..085e76f --- /dev/null +++ b/SBrowser.xcodeproj/xcshareddata/xcschemes/SBrowser.xcscheme @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SBrowser/AppDelegate.swift b/SBrowser/AppDelegate.swift new file mode 100644 index 0000000..679a446 --- /dev/null +++ b/SBrowser/AppDelegate.swift @@ -0,0 +1,25 @@ +// +// AppDelegate.swift +// SBrowser +// +// Created by James Magahern on 7/21/20. +// + +import UIKit + +@main +class AppDelegate: UIResponder, UIApplicationDelegate { + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool + { + return true + } + + // MARK: UISceneSession Lifecycle + + func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration + { + return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) + } +} + diff --git a/SBrowser/Backend/ResourcePolicyManager.swift b/SBrowser/Backend/ResourcePolicyManager.swift new file mode 100644 index 0000000..a78448d --- /dev/null +++ b/SBrowser/Backend/ResourcePolicyManager.swift @@ -0,0 +1,31 @@ +// +// ResourcePolicyManager.swift +// SBrowser +// +// Created by James Magahern on 7/22/20. +// + +import Foundation + +class ResourcePolicyManager: NSObject, SBRResourceOriginPolicyDataSource +{ + static let AllowedOriginsDefaultsKey = "allowedOrigins" + private var allowedOriginSet: Set = { + if let allowedOrigins = UserDefaults.standard.array(forKey: AllowedOriginsDefaultsKey) as? [String] { + return Set(allowedOrigins) + } + + return Set() + }() + + func allowedOriginsForScriptResources() -> Set + { + allowedOriginSet + } + + func allowOriginToLoadScriptResources(_ origin: String) + { + allowedOriginSet.formUnion([ origin ]) + UserDefaults.standard.set(allowedOriginSet, forKey: Self.AllowedOriginsDefaultsKey) + } +} diff --git a/SBrowser/Browser View/BrowserView.swift b/SBrowser/Browser View/BrowserView.swift new file mode 100644 index 0000000..2fde612 --- /dev/null +++ b/SBrowser/Browser View/BrowserView.swift @@ -0,0 +1,23 @@ +// +// BrowserView.swift +// SBrowser +// +// Created by James Magahern on 7/21/20. +// + +import UIKit +import WebKit + +class BrowserView: UIView +{ + var webView: WKWebView? { + didSet { addSubview(webView!); setNeedsLayout() } + } + + override func layoutSubviews() + { + super.layoutSubviews() + webView?.frame = bounds + } + +} diff --git a/SBrowser/Browser View/BrowserViewController.swift b/SBrowser/Browser View/BrowserViewController.swift new file mode 100644 index 0000000..2d8a854 --- /dev/null +++ b/SBrowser/Browser View/BrowserViewController.swift @@ -0,0 +1,63 @@ +// +// BrowserViewController.swift +// SBrowser +// +// Created by James Magahern on 7/21/20. +// + +import UIKit + +class BrowserViewController: UIViewController, SBRProcessBundleBridgeDelegate +{ + let bridge = SBRProcessBundleBridge() + let browserView = BrowserView() + + private let policyManager = ResourcePolicyManager() + private var blockedScriptOrigins = Set() + private var scriptBlockerButtonItem: UIBarButtonItem + + init() + { + scriptBlockerButtonItem = UIBarButtonItem(title: "0", image: nil, primaryAction: UIAction(handler: { action in + // present + }), menu: nil) + + super.init(nibName: nil, bundle: nil) + } + + required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } + + override func loadView() + { + bridge.delegate = self + bridge.policyDataSource = policyManager + + browserView.webView = bridge.webView + browserView.webView?.allowsBackForwardNavigationGestures = true + + self.view = browserView + } + + override func viewDidLoad() + { + let request = URLRequest(url: URL(string: "https://yahoo.com")!) + browserView.webView?.load(request) + + navigationItem.rightBarButtonItem = scriptBlockerButtonItem + } + + private func updateScriptBlockerButton() + { + scriptBlockerButtonItem.title = "\(blockedScriptOrigins.count)" + } + + // MARK: SBRProcessBundleBridgeDelegate + + func webProcess(_ bridge: SBRProcessBundleBridge, didBlockScriptResourceFromOrigin origin: String) + { + print("Blocked script resource from origin: \(origin)") + + blockedScriptOrigins.formUnion([ origin ]) + updateScriptBlockerButton() + } +} diff --git a/SBrowser/Browser View/SBRProcessBundleBridge.h b/SBrowser/Browser View/SBRProcessBundleBridge.h new file mode 100644 index 0000000..51b3d05 --- /dev/null +++ b/SBrowser/Browser View/SBRProcessBundleBridge.h @@ -0,0 +1,37 @@ +// +// SBRProcessBundleBridge.h +// SBrowser +// +// Created by James Magahern on 7/22/20. +// + +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol SBRResourceOriginPolicyDataSource + +/// Returns a list of origins (e.g., "buzzert.net") for which we are allowed to load script resources from +- (NSSet *)allowedOriginsForScriptResources; + +@end + +@class SBRProcessBundleBridge; +@protocol SBRProcessBundleBridgeDelegate +- (void)webProcess:(SBRProcessBundleBridge *)bridge didBlockScriptResourceFromOrigin:(NSString *)origin; + +@end + +@interface SBRProcessBundleBridge : NSObject + +@property (nonatomic, readonly) WKWebView *webView; + +@property (nonatomic, weak) id delegate; +@property (nonatomic, weak) id policyDataSource; + +- (void)policyDataSourceDidChange; + +@end + +NS_ASSUME_NONNULL_END diff --git a/SBrowser/Browser View/SBRProcessBundleBridge.m b/SBrowser/Browser View/SBRProcessBundleBridge.m new file mode 100644 index 0000000..bd68ea5 --- /dev/null +++ b/SBrowser/Browser View/SBRProcessBundleBridge.m @@ -0,0 +1,82 @@ +// +// SBRProcessBundleBridge.m +// SBrowser +// +// Created by James Magahern on 7/22/20. +// + +#import "SBRProcessBundleBridge.h" + +#import "SBRWebProcessDelegate.h" +#import "SBRWebProcessProxy.h" + +#import +#import +#import + +#import +#import +#import + +@interface SBRProcessBundleBridge () + +@end + +@implementation SBRProcessBundleBridge { + WKWebView *_webView; + id _webProcessProxy; +} + +- (WKWebView *)webView +{ + if (!_webView) { + // Inject bundle + _WKProcessPoolConfiguration *poolConfiguration = [[_WKProcessPoolConfiguration alloc] init]; + NSURL *bundleURL = [[[NSBundle mainBundle] builtInPlugInsURL] URLByAppendingPathComponent:@"SBrowserProcessBundle.bundle"]; + [poolConfiguration setInjectedBundleURL:bundleURL]; + + // Set up process pool + WKProcessPool *processPool = [[WKProcessPool alloc] _initWithConfiguration:poolConfiguration]; + WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init]; + configuration.processPool = processPool; + + // Instantiate web view + WKWebView *webView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:configuration]; + + // Configure proxy interface (interface to remote web process) + _WKRemoteObjectInterface *proxyInterface = [_WKRemoteObjectInterface remoteObjectInterfaceWithProtocol:@protocol(SBRWebProcessProxy)]; + _webProcessProxy = [[webView _remoteObjectRegistry] remoteObjectProxyWithInterface:proxyInterface]; + + // Configure delegate interface (registering us as the web process delegate for the remote process) + _WKRemoteObjectInterface *delegateInterface = [_WKRemoteObjectInterface remoteObjectInterfaceWithProtocol:@protocol(SBRWebProcessDelegate)]; + [[webView _remoteObjectRegistry] registerExportedObject:self interface:delegateInterface]; + + _webView = webView; + } + + return _webView; +} + +#pragma mark + +- (void)webProcessDidConnect +{ + NSLog(@"SBRProcessBundleBridge: did connect. Saying hello, syncing allowlist"); + [_webProcessProxy hello]; + [self policyDataSourceDidChange]; +} + +- (void)webProcessDidLoadScriptWithOrigin:(NSString *)origin +{ + [_delegate webProcess:self didBlockScriptResourceFromOrigin:origin]; +} + +#pragma mark Actions + +- (void)policyDataSourceDidChange +{ + NSSet *allowedOrigins = [_policyDataSource allowedOriginsForScriptResources]; + [_webProcessProxy syncAllowedResourceOrigins:allowedOrigins]; +} + +@end diff --git a/SBrowser/SceneDelegate.swift b/SBrowser/SceneDelegate.swift new file mode 100644 index 0000000..34fe6ea --- /dev/null +++ b/SBrowser/SceneDelegate.swift @@ -0,0 +1,27 @@ +// +// SceneDelegate.swift +// SBrowser +// +// Created by James Magahern on 7/21/20. +// + +import UIKit + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + var window: UIWindow? + let navigationController = UINavigationController() + let browserViewController = BrowserViewController() + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) + { + guard let windowScene = (scene as? UIWindowScene) else { return } + + navigationController.viewControllers = [ browserViewController ] + + let window = UIWindow(windowScene: windowScene) + window.rootViewController = navigationController + window.makeKeyAndVisible() + self.window = window + } +} + diff --git a/SBrowser/Supporting Files/Assets.xcassets/AccentColor.colorset/Contents.json b/SBrowser/Supporting Files/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/SBrowser/Supporting Files/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/SBrowser/Supporting Files/Assets.xcassets/AppIcon.appiconset/Contents.json b/SBrowser/Supporting Files/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..9221b9b --- /dev/null +++ b/SBrowser/Supporting Files/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "83.5x83.5" + }, + { + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/SBrowser/Supporting Files/Assets.xcassets/Contents.json b/SBrowser/Supporting Files/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/SBrowser/Supporting Files/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/SBrowser/Supporting Files/Base.lproj/LaunchScreen.storyboard b/SBrowser/Supporting Files/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..865e932 --- /dev/null +++ b/SBrowser/Supporting Files/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SBrowser/Supporting Files/Info.plist b/SBrowser/Supporting Files/Info.plist new file mode 100644 index 0000000..23bccd7 --- /dev/null +++ b/SBrowser/Supporting Files/Info.plist @@ -0,0 +1,64 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + + + + + UIApplicationSupportsIndirectInputEvents + + UILaunchStoryboardName + LaunchScreen + UIRequiredDeviceCapabilities + + armv7 + + UIStatusBarHidden + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/SBrowser/Supporting Files/SBrowser-Bridging-Header.h b/SBrowser/Supporting Files/SBrowser-Bridging-Header.h new file mode 100644 index 0000000..77ca5ef --- /dev/null +++ b/SBrowser/Supporting Files/SBrowser-Bridging-Header.h @@ -0,0 +1,5 @@ +// +// Use this file to import your target's public headers that you would like to expose to Swift. +// + +#import "SBRProcessBundleBridge.h" diff --git a/SBrowser/Supporting Files/SBrowser.entitlements b/SBrowser/Supporting Files/SBrowser.entitlements new file mode 100644 index 0000000..ee95ab7 --- /dev/null +++ b/SBrowser/Supporting Files/SBrowser.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.network.client + + + diff --git a/SBrowserProcessBundle/Info.plist b/SBrowserProcessBundle/Info.plist new file mode 100644 index 0000000..3c9d48e --- /dev/null +++ b/SBrowserProcessBundle/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + NSPrincipalClass + SBRProcessPlugin + + diff --git a/SBrowserProcessBundle/SBRProcessPlugin.h b/SBrowserProcessBundle/SBRProcessPlugin.h new file mode 100644 index 0000000..f3d6dc3 --- /dev/null +++ b/SBrowserProcessBundle/SBRProcessPlugin.h @@ -0,0 +1,17 @@ +// +// SBRProcessPlugin.h +// SBrowserProcessBundle +// +// Created by James Magahern on 7/22/20. +// + +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface SBRProcessPlugin : NSObject + +@end + +NS_ASSUME_NONNULL_END diff --git a/SBrowserProcessBundle/SBRProcessPlugin.m b/SBrowserProcessBundle/SBRProcessPlugin.m new file mode 100644 index 0000000..f3ecd85 --- /dev/null +++ b/SBrowserProcessBundle/SBRProcessPlugin.m @@ -0,0 +1,86 @@ +// +// SBRProcessPlugin.m +// SBrowserProcessBundle +// +// Created by James Magahern on 7/22/20. +// + +#import "SBRProcessPlugin.h" + +#import "SBRWebProcessDelegate.h" +#import "SBRWebProcessProxy.h" + +#import +#import +#import +#import +#import + +@interface SBRProcessPlugin () +@property (nonatomic, strong) id processDelegate; +@property (nonatomic, strong) NSMutableSet *allowedResourceOrigins; +@end + +@implementation SBRProcessPlugin + ++ (void)initialize +{ + [super initialize]; + NSLog(@"SBRProcessPlugin Initialized"); +} + +#pragma mark + +- (void)hello +{ + NSLog(@"SBRProcessPlugin: Helloooooo"); +} + +- (void)syncAllowedResourceOrigins:(NSSet *)allowedOrigins +{ + if (!_allowedResourceOrigins) { + _allowedResourceOrigins = [allowedOrigins mutableCopy]; + } else { + [_allowedResourceOrigins unionSet:allowedOrigins]; + } +} + +#pragma mark + +- (void)webProcessPlugIn:(WKWebProcessPlugInController *)plugInController didCreateBrowserContextController:(WKWebProcessPlugInBrowserContextController *)browserContextController +{ + _WKRemoteObjectInterface *proxyInterface = [_WKRemoteObjectInterface remoteObjectInterfaceWithProtocol:@protocol(SBRWebProcessProxy)]; + [browserContextController._remoteObjectRegistry registerExportedObject:self interface:proxyInterface]; + + _WKRemoteObjectInterface *eventListenerInterface = [_WKRemoteObjectInterface remoteObjectInterfaceWithProtocol:@protocol(SBRWebProcessDelegate)]; + self.processDelegate = [browserContextController._remoteObjectRegistry remoteObjectProxyWithInterface:eventListenerInterface]; + + browserContextController.loadDelegate = self; + + [[self processDelegate] webProcessDidConnect]; +} + +#pragma mark + +- (NSURLRequest *)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller frame:(WKWebProcessPlugInFrame *)frame willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse +{ + NSLog(@"SBRProcessPlugin: Sending request: %@", request); + + NSURL *requestURL = [request URL]; + NSString *originString = [requestURL host]; + NSString *requestExtension = [requestURL pathExtension]; + if (requestExtension.length > 0 && [requestExtension isEqualToString:@"js"]) { + [[self processDelegate] webProcessDidLoadScriptWithOrigin:originString]; + + if ([_allowedResourceOrigins containsObject:originString]) { + NSLog(@"SBRProcessPlugin: Allowing whitelisted requestURL: %@", requestURL); + } else { + NSLog(@"SBRProcessPlugin: Blocking requestURL: %@", requestURL); + request = nil; + } + } + + return request; +} + +@end diff --git a/SBrowserProcessBundle/SBRWebProcessDelegate.h b/SBrowserProcessBundle/SBRWebProcessDelegate.h new file mode 100644 index 0000000..b785497 --- /dev/null +++ b/SBrowserProcessBundle/SBRWebProcessDelegate.h @@ -0,0 +1,15 @@ +// +// SBRWebProcessDelegate.h +// SBrowser +// +// Created by James Magahern on 7/22/20. +// + +#import + +@protocol SBRWebProcessDelegate + +- (void)webProcessDidConnect; +- (void)webProcessDidLoadScriptWithOrigin:(NSString *)origin; + +@end diff --git a/SBrowserProcessBundle/SBRWebProcessProxy.h b/SBrowserProcessBundle/SBRWebProcessProxy.h new file mode 100644 index 0000000..ac0c0ab --- /dev/null +++ b/SBrowserProcessBundle/SBRWebProcessProxy.h @@ -0,0 +1,15 @@ +// +// SBRWebProcessProxy.h +// SBrowser +// +// Created by James Magahern on 7/22/20. +// + +#import + +@protocol SBRWebProcessProxy + +- (void)hello; +- (void)syncAllowedResourceOrigins:(NSSet *)allowedOrigins; + +@end