diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 918aaf55be2..bab431a75d6 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -2956,8 +2956,8 @@ "general": { "bzlTransitiveDigest": "YjE3dFjYQ4sj5gn2Iz1cWVK14/ZJ5cmnAUUGjDbACAA=", "recordedFileInputs": { - "@@//Package.resolved": "6fa0a5ab5dee4c2acbe04fd63786a2cf6202d00f845eaf6d1e08e18de54371e6", - "@@//Package.swift": "dcdee2ad7bd423078b3d64ca8f64819ec28115d20bff39b44c32996b0c9bbd9c" + "@@//Package.resolved": "06bfbab719e4a9a5c518560ccd38f94fac37034aa6d6b4ca345c59df1237d28a", + "@@//Package.swift": "5ec7a4bc98efbe05c2f49eace2c89b1ef5b01d545d1474b5a2e2a2ad98c32a2e" }, "recordedDirentsInputs": {}, "envVariables": {}, @@ -3003,7 +3003,7 @@ "ruleClassName": "swift_package", "attributes": { "bazel_package_name": "swiftpkg_ton_api_swift", - "commit": "c1d5a7912480d1794097f4fb8241c3176f394384", + "commit": "d57d457cbaea081467ae65648e92fc6094ea342b", "remote": "https://github.com/tonkeeper/ton-api-swift", "init_submodules": false, "recursive_init_submodules": true, @@ -3183,7 +3183,7 @@ "ruleClassName": "swift_package", "attributes": { "bazel_package_name": "swiftpkg_walletconnectswiftv2", - "commit": "6b48ddc4bcde620310c5ee55388c022a19da5a25", + "commit": "1427dcb1514e5d6f167ee7a41478ea1d6a6d8cc5", "remote": "https://github.com/WalletConnect/WalletConnectSwiftV2.git", "init_submodules": false, "recursive_init_submodules": true, @@ -3413,11 +3413,21 @@ } }, "swiftpkg_nicegram_assistant_ios": { - "bzlFile": "@@rules_swift_package_manager~//swiftpkg/internal:local_swift_package.bzl", - "ruleClassName": "local_swift_package", + "bzlFile": "@@rules_swift_package_manager~//swiftpkg/internal:swift_package.bzl", + "ruleClassName": "swift_package", "attributes": { "bazel_package_name": "swiftpkg_nicegram_assistant_ios", - "path": "/Users/denisshilovich/work/nicegram-assistant-ios" + "commit": "1b82457f99a129e8c97d8314b405e1e0e411a8a6", + "remote": "git@bitbucket.org:mobyrix/nicegram-assistant-ios.git", + "init_submodules": false, + "recursive_init_submodules": true, + "patch_args": [ + "-p0" + ], + "patch_cmds": [], + "patch_cmds_win": [], + "patch_tool": "", + "patches": [] } }, "swiftpkg_fetch_node_details_swift": { @@ -3655,11 +3665,21 @@ } }, "swiftpkg_nicegram_wallet_ios": { - "bzlFile": "@@rules_swift_package_manager~//swiftpkg/internal:local_swift_package.bzl", - "ruleClassName": "local_swift_package", + "bzlFile": "@@rules_swift_package_manager~//swiftpkg/internal:swift_package.bzl", + "ruleClassName": "swift_package", "attributes": { "bazel_package_name": "swiftpkg_nicegram_wallet_ios", - "path": "/Users/denisshilovich/work/nicegram-wallet-ios" + "commit": "794177222256849249416a30fa8e3dc7560507c8", + "remote": "git@bitbucket.org:mobyrix/nicegram-wallet-ios.git", + "init_submodules": false, + "recursive_init_submodules": true, + "patch_args": [ + "-p0" + ], + "patch_cmds": [], + "patch_cmds_win": [], + "patch_tool": "", + "patches": [] } }, "swiftpkg_rive_ios": { diff --git a/Package.resolved b/Package.resolved index a477bf10652..9cbc1e51bb6 100644 --- a/Package.resolved +++ b/Package.resolved @@ -123,7 +123,7 @@ "location" : "git@bitbucket.org:mobyrix/nicegram-assistant-ios.git", "state" : { "branch" : "develop", - "revision" : "e47489635ad1e96913dd1da01d9b1164494c722d" + "revision" : "1b82457f99a129e8c97d8314b405e1e0e411a8a6" } }, { @@ -132,7 +132,7 @@ "location" : "git@bitbucket.org:mobyrix/nicegram-wallet-ios.git", "state" : { "branch" : "develop", - "revision" : "60d741c4fbef9808061d0eb7df0207bd803cdcf2" + "revision" : "3a10f5bd47e6251a6bf4d8c80db11867cfc803d9" } }, { diff --git a/submodules/BrowserUI/BUILD b/submodules/BrowserUI/BUILD index 15478db26af..4a698a572e9 100644 --- a/submodules/BrowserUI/BUILD +++ b/submodules/BrowserUI/BUILD @@ -1,5 +1,9 @@ load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") +NGDEPS = [ + "@swiftpkg_nicegram_wallet_ios//:NicegramWallet", +] + swift_library( name = "BrowserUI", module_name = "BrowserUI", @@ -9,7 +13,7 @@ swift_library( copts = [ #"-warnings-as-errors", ], - deps = [ + deps = NGDEPS + [ "//submodules/SSignalKit/SwiftSignalKit", "//submodules/AsyncDisplayKit", "//submodules/Display", diff --git a/submodules/BrowserUI/Sources/BrowserWebContent.swift b/submodules/BrowserUI/Sources/BrowserWebContent.swift index de137be6504..d34787b4b49 100644 --- a/submodules/BrowserUI/Sources/BrowserWebContent.swift +++ b/submodules/BrowserUI/Sources/BrowserWebContent.swift @@ -1,3 +1,6 @@ +// MARK: Nicegram Wallet +import NicegramWallet +// import Foundation import UIKit import Display @@ -203,6 +206,10 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU private var tempFile: TempBoxFile? + // MARK: Nicegram Wallet + private let nicegramWalletJsInjector = WalletJsInjector() + // + init(context: AccountContext, presentationData: PresentationData, url: String, preferredConfiguration: WKWebViewConfiguration? = nil) { self.context = context self.uuid = UUID() @@ -319,6 +326,14 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU handleScriptMessageImpl = { [weak self] message in self?.handleScriptMessage(message) } + + // MARK: Nicegram Wallet + nicegramWalletJsInjector.inject( + in: self.webView, + injectTonJs: false, + currentChain: { nil } + ) + // } required init?(coder: NSCoder) { @@ -712,6 +727,13 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU // }) // } else { if let url = navigationAction.request.url?.absoluteString { + // MARK: Nicegram Wallet + if nicegramWalletJsInjector.handle(url: url) { + decisionHandler(.cancel, preferences) + return + } + // + if (navigationAction.targetFrame == nil || navigationAction.targetFrame?.isMainFrame == true) && (isTelegramMeLink(url) || isTelegraPhLink(url)) && !url.contains("/auth/push?") && !self._state.url.contains("/auth/push?") { decisionHandler(.cancel, preferences) self.minimize() @@ -788,6 +810,12 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU func webView(_ webView: WKWebView, createWebViewWith configuration: WKWebViewConfiguration, for navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? { if navigationAction.targetFrame == nil { if let url = navigationAction.request.url?.absoluteString { + // MARK: Nicegram Wallet + if nicegramWalletJsInjector.handle(url: url) { + return nil + } + // + if isTelegramMeLink(url) || isTelegraPhLink(url) { self.minimize() self.openAppUrl(url) diff --git a/submodules/TelegramUI/Sources/Nicegram/NGDeeplinkHandler.swift b/submodules/TelegramUI/Sources/Nicegram/NGDeeplinkHandler.swift index 4f89a25f5e8..49f995ab328 100644 --- a/submodules/TelegramUI/Sources/Nicegram/NGDeeplinkHandler.swift +++ b/submodules/TelegramUI/Sources/Nicegram/NGDeeplinkHandler.swift @@ -113,8 +113,7 @@ class NGDeeplinkHandler { } return true default: - showUpdateAppAlert() - return true + return false } } } @@ -228,34 +227,6 @@ private extension NGDeeplinkHandler { } return true } - - func showUpdateAppAlert() { - let alert = UIAlertController( - title: "Update the app", - message: "Please update the app to use the newest features!", - preferredStyle: .alert - ) - - alert.addAction( - UIAlertAction( - title: "Close", - style: .cancel - ) - ) - - alert.addAction( - UIAlertAction( - title: "Update", - style: .default, - handler: { _ in - let urlOpener = CoreContainer.shared.urlOpener() - urlOpener.open(.appStoreAppUrl) - } - ) - ) - - UIApplication.topViewController?.present(alert, animated: true) - } } // MARK: - Helpers diff --git a/submodules/TelegramUI/Sources/OpenUrl.swift b/submodules/TelegramUI/Sources/OpenUrl.swift index 68565fec965..e53e697f759 100644 --- a/submodules/TelegramUI/Sources/OpenUrl.swift +++ b/submodules/TelegramUI/Sources/OpenUrl.swift @@ -1,4 +1,5 @@ // MARK: Nicegram Deeplink +import NGCore import NicegramWallet // import Foundation @@ -1073,6 +1074,9 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur if let convertedUrl = convertedUrl { handleInternalUrl(convertedUrl) + // MARK: Nicegram Deeplink, added 'else' block + } else { + showUpdateAppAlert() } return } @@ -1180,3 +1184,33 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur continueHandling() } } + +// MARK: Nicegram Deeplink +private func showUpdateAppAlert() { + let alert = UIAlertController( + title: "Update the app", + message: "Please update the app to use the newest features!", + preferredStyle: .alert + ) + + alert.addAction( + UIAlertAction( + title: "Close", + style: .cancel + ) + ) + + alert.addAction( + UIAlertAction( + title: "Update", + style: .default, + handler: { _ in + let urlOpener = CoreContainer.shared.urlOpener() + urlOpener.open(.appStoreAppUrl) + } + ) + ) + + UIApplication.topViewController?.present(alert, animated: true) +} +// diff --git a/submodules/WebUI/BUILD b/submodules/WebUI/BUILD index 16405520eba..be55759af0e 100644 --- a/submodules/WebUI/BUILD +++ b/submodules/WebUI/BUILD @@ -1,5 +1,9 @@ load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") +NGDEPS = [ + "@swiftpkg_nicegram_wallet_ios//:NicegramWallet", +] + swift_library( name = "WebUI", module_name = "WebUI", @@ -9,7 +13,7 @@ swift_library( copts = [ #"-warnings-as-errors", ], - deps = [ + deps = NGDEPS + [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/Display:Display", diff --git a/submodules/WebUI/Sources/WebAppController.swift b/submodules/WebUI/Sources/WebAppController.swift index 954c427f964..40c4537651e 100644 --- a/submodules/WebUI/Sources/WebAppController.swift +++ b/submodules/WebUI/Sources/WebAppController.swift @@ -1,3 +1,6 @@ +// MARK: Nicegram Wallet +import NicegramWallet +// import Foundation import UIKit import WebKit @@ -164,6 +167,10 @@ public final class WebAppController: ViewController, AttachmentContainable { private var validLayout: (ContainerViewLayout, CGFloat)? + // MARK: Nicegram Wallet + private let nicegramWalletJsInjector = WalletJsInjector() + // + init(context: AccountContext, controller: WebAppController) { self.context = context self.controller = controller @@ -301,6 +308,14 @@ public final class WebAppController: ViewController, AttachmentContainable { } self.icon = icon }) + + // MARK: Nicegram Wallet + nicegramWalletJsInjector.inject( + in: webView, + injectTonJs: false, + currentChain: { nil } + ) + // } deinit { @@ -431,6 +446,13 @@ public final class WebAppController: ViewController, AttachmentContainable { func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { if let url = navigationAction.request.url?.absoluteString { + // MARK: Nicegram Wallet + if nicegramWalletJsInjector.handle(url: url) { + decisionHandler(.cancel) + return + } + // + if isTelegramMeLink(url) || isTelegraPhLink(url) { decisionHandler(.cancel) self.controller?.openUrl(url, true, {}) @@ -444,6 +466,12 @@ public final class WebAppController: ViewController, AttachmentContainable { func webView(_ webView: WKWebView, createWebViewWith configuration: WKWebViewConfiguration, for navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? { if navigationAction.targetFrame == nil, let url = navigationAction.request.url { + // MARK: Nicegram Wallet + if nicegramWalletJsInjector.handle(url: url.absoluteString) { + return nil + } + // + self.controller?.openUrl(url.absoluteString, true, {}) } return nil diff --git a/versions.json b/versions.json index 3b8bd0fc865..b94a7caa818 100644 --- a/versions.json +++ b/versions.json @@ -1,5 +1,5 @@ { - "app": "1.7.2", + "app": "1.7.4", "xcode": "15.2", "bazel": "7.1.1", "macos": "13.0"