2024-11-14 18:12:51 +00:00
|
|
|
//
|
2024-12-08 17:56:39 +00:00
|
|
|
// TunnelContext+Shared.swift
|
2024-11-14 18:12:51 +00:00
|
|
|
// Passepartout
|
|
|
|
//
|
|
|
|
// Created by Davide De Rosa on 11/14/24.
|
|
|
|
// Copyright (c) 2024 Davide De Rosa. All rights reserved.
|
|
|
|
//
|
|
|
|
// https://github.com/passepartoutvpn
|
|
|
|
//
|
|
|
|
// This file is part of Passepartout.
|
|
|
|
//
|
|
|
|
// Passepartout is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Passepartout is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Passepartout. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
//
|
|
|
|
|
|
|
|
import CommonLibrary
|
|
|
|
import CommonUtils
|
|
|
|
import Foundation
|
|
|
|
import PassepartoutKit
|
|
|
|
|
2024-12-08 17:56:39 +00:00
|
|
|
extension TunnelContext {
|
|
|
|
static let shared: TunnelContext = {
|
|
|
|
let dependencies: Dependencies = .shared
|
|
|
|
let iapManager = IAPManager(
|
|
|
|
inAppHelper: dependencies.appProductHelper(),
|
|
|
|
receiptReader: dependencies.tunnelReceiptReader(),
|
|
|
|
betaChecker: dependencies.betaChecker(),
|
|
|
|
productsAtBuild: dependencies.productsAtBuild()
|
|
|
|
)
|
2024-12-10 13:13:10 +00:00
|
|
|
let processor = DefaultTunnelProcessor()
|
2024-12-08 17:56:39 +00:00
|
|
|
return TunnelContext(
|
|
|
|
iapManager: iapManager,
|
|
|
|
processor: processor
|
|
|
|
)
|
|
|
|
}()
|
2024-12-08 15:05:23 +00:00
|
|
|
}
|
|
|
|
|
2024-12-02 09:40:25 +00:00
|
|
|
// MARK: - Dependencies
|
|
|
|
|
2024-12-08 17:56:39 +00:00
|
|
|
private extension Dependencies {
|
|
|
|
func tunnelReceiptReader() -> AppReceiptReader {
|
2024-11-14 18:12:51 +00:00
|
|
|
FallbackReceiptReader(
|
|
|
|
main: StoreKitReceiptReader(),
|
2024-11-14 21:21:56 +00:00
|
|
|
beta: KvittoReceiptReader(url: betaReceiptURL)
|
2024-11-14 18:12:51 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2024-12-08 17:56:39 +00:00
|
|
|
var betaReceiptURL: URL {
|
2024-11-14 21:21:56 +00:00
|
|
|
BundleConfiguration.urlForBetaReceipt // copied by AppContext.onLaunch
|
2024-11-14 18:12:51 +00:00
|
|
|
}
|
|
|
|
}
|