Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

Commit e273d5a

Browse files
App groups (#2495)
Task/Issue URL: https://app.asana.com/0/1199230911884351/1206909771441783/f **Description**: - All targets are now in the SUBSCRIPTION_APP_GROUP - AccountManager fake init() removed - Reduced the amount of AccountManager initialisation
1 parent e82a088 commit e273d5a

File tree

36 files changed

+114
-145
lines changed

36 files changed

+114
-145
lines changed

Configuration/AppStore.xcconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ NETP_APP_GROUP[config=Review][sdk=macos*] = $(NETP_BASE_APP_GROUP).review
4141
NETP_APP_GROUP[config=Debug][sdk=macos*] = $(NETP_BASE_APP_GROUP).debug
4242
NETP_APP_GROUP[config=Release][sdk=macos*] = $(NETP_BASE_APP_GROUP)
4343

44-
SUBSCRIPTION_BASE_APP_GROUP = $(DEVELOPMENT_TEAM).com.duckduckgo.macos.browser.subscription
44+
SUBSCRIPTION_BASE_APP_GROUP = $(DEVELOPMENT_TEAM).$(MAIN_BUNDLE_IDENTIFIER_PREFIX).subscription
4545
SUBSCRIPTION_APP_GROUP[config=CI][sdk=*] = $(SUBSCRIPTION_BASE_APP_GROUP).debug
4646
SUBSCRIPTION_APP_GROUP[config=Review][sdk=*] = $(SUBSCRIPTION_BASE_APP_GROUP).review
4747
SUBSCRIPTION_APP_GROUP[config=Debug][sdk=*] = $(SUBSCRIPTION_BASE_APP_GROUP).debug

Configuration/DeveloperID.xcconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ NETP_APP_GROUP[config=Review][sdk=*] = $(NETP_BASE_APP_GROUP).review
4545
NETP_APP_GROUP[config=Debug][sdk=*] = $(NETP_BASE_APP_GROUP).debug
4646
NETP_APP_GROUP[config=Release][sdk=*] = $(NETP_BASE_APP_GROUP)
4747

48-
SUBSCRIPTION_BASE_APP_GROUP = $(DEVELOPMENT_TEAM).com.duckduckgo.macos.browser.subscription
48+
SUBSCRIPTION_BASE_APP_GROUP = $(DEVELOPMENT_TEAM).$(MAIN_BUNDLE_IDENTIFIER_PREFIX).subscription
4949
SUBSCRIPTION_APP_GROUP[config=CI][sdk=*] = $(SUBSCRIPTION_BASE_APP_GROUP).debug
5050
SUBSCRIPTION_APP_GROUP[config=Review][sdk=*] = $(SUBSCRIPTION_BASE_APP_GROUP).review
5151
SUBSCRIPTION_APP_GROUP[config=Debug][sdk=*] = $(SUBSCRIPTION_BASE_APP_GROUP).debug

DuckDuckGo.xcodeproj/project.pbxproj

-12
Original file line numberDiff line numberDiff line change
@@ -3226,11 +3226,6 @@
32263226
EAE42800275D47FA00DAC26B /* ClickToLoadModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAE427FF275D47FA00DAC26B /* ClickToLoadModel.swift */; };
32273227
EAFAD6CA2728BD1200F9DF00 /* clickToLoad.js in Resources */ = {isa = PBXBuildFile; fileRef = EAFAD6C92728BD1200F9DF00 /* clickToLoad.js */; };
32283228
EE0429E02BA31D2F009EB20F /* FindInPageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE0429DF2BA31D2F009EB20F /* FindInPageTests.swift */; };
3229-
EE0629722B90EE8C00D868B4 /* AccountManagerExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE0629712B90EE8C00D868B4 /* AccountManagerExtension.swift */; };
3230-
EE0629732B90EE8C00D868B4 /* AccountManagerExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE0629712B90EE8C00D868B4 /* AccountManagerExtension.swift */; };
3231-
EE0629742B90EE8C00D868B4 /* AccountManagerExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE0629712B90EE8C00D868B4 /* AccountManagerExtension.swift */; };
3232-
EE0629752B90EE8C00D868B4 /* AccountManagerExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE0629712B90EE8C00D868B4 /* AccountManagerExtension.swift */; };
3233-
EE0629762B90EE8C00D868B4 /* AccountManagerExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE0629712B90EE8C00D868B4 /* AccountManagerExtension.swift */; };
32343229
EE2F9C5B2B90F2FF00D45FC9 /* Subscription in Frameworks */ = {isa = PBXBuildFile; productRef = EE2F9C5A2B90F2FF00D45FC9 /* Subscription */; };
32353230
EE339228291BDEFD009F62C1 /* JSAlertController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE339227291BDEFD009F62C1 /* JSAlertController.swift */; };
32363231
EE3424602BA0853900173B1B /* VPNUninstaller.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE34245D2BA0853900173B1B /* VPNUninstaller.swift */; };
@@ -4663,7 +4658,6 @@
46634658
EAE427FF275D47FA00DAC26B /* ClickToLoadModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ClickToLoadModel.swift; sourceTree = "<group>"; };
46644659
EAFAD6C92728BD1200F9DF00 /* clickToLoad.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = clickToLoad.js; sourceTree = "<group>"; };
46654660
EE0429DF2BA31D2F009EB20F /* FindInPageTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FindInPageTests.swift; sourceTree = "<group>"; };
4666-
EE0629712B90EE8C00D868B4 /* AccountManagerExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountManagerExtension.swift; sourceTree = "<group>"; };
46674661
EE339227291BDEFD009F62C1 /* JSAlertController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSAlertController.swift; sourceTree = "<group>"; };
46684662
EE34245D2BA0853900173B1B /* VPNUninstaller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPNUninstaller.swift; sourceTree = "<group>"; };
46694663
EE66418B2B9B1981005BCD17 /* NetworkProtectionTokenStore+SubscriptionTokenKeychainStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NetworkProtectionTokenStore+SubscriptionTokenKeychainStorage.swift"; sourceTree = "<group>"; };
@@ -5155,7 +5149,6 @@
51555149
1EA7B8D62B7E124E000330A4 /* Subscription */ = {
51565150
isa = PBXGroup;
51575151
children = (
5158-
EE0629712B90EE8C00D868B4 /* AccountManagerExtension.swift */,
51595152
7BBA7CE52BAB03C1007579A3 /* DefaultSubscriptionFeatureAvailability+DefaultInitializer.swift */,
51605153
);
51615154
path = Subscription;
@@ -10505,7 +10498,6 @@
1050510498
B684121D2B6A1D880092F66A /* ErrorPageHTMLTemplate.swift in Sources */,
1050610499
3706FBD2293F65D500E42796 /* RunningApplicationCheck.swift in Sources */,
1050710500
3706FBD3293F65D500E42796 /* StatePersistenceService.swift in Sources */,
10508-
EE0629732B90EE8C00D868B4 /* AccountManagerExtension.swift in Sources */,
1050910501
3706FBD4293F65D500E42796 /* WindowManager+StateRestoration.swift in Sources */,
1051010502
7B430EA22A71411A00BAC4A1 /* NetworkProtectionSimulateFailureMenu.swift in Sources */,
1051110503
3706FBD5293F65D500E42796 /* TabCollection+NSSecureCoding.swift in Sources */,
@@ -11182,7 +11174,6 @@
1118211174
7B8DB31A2B504D7500EC16DA /* VPNAppEventsHandler.swift in Sources */,
1118311175
7BA7CC532AD11FCE0042E5CE /* Bundle+VPN.swift in Sources */,
1118411176
7BFE95562A9DF29B0081ABE9 /* UserDefaults+NetworkProtectionWaitlist.swift in Sources */,
11185-
EE0629742B90EE8C00D868B4 /* AccountManagerExtension.swift in Sources */,
1118611177
7BA7CC5D2AD120C30042E5CE /* EventMapping+NetworkProtectionError.swift in Sources */,
1118711178
7BA7CC4A2AD11EA00042E5CE /* NetworkProtectionTunnelController.swift in Sources */,
1118811179
EE3424602BA0853900173B1B /* VPNUninstaller.swift in Sources */,
@@ -11217,7 +11208,6 @@
1121711208
4B0EF7292B5780EB009D6481 /* VPNAppEventsHandler.swift in Sources */,
1121811209
7BA7CC412AD11E420042E5CE /* NetworkProtectionBouncer.swift in Sources */,
1121911210
4BF0E5082AD2551A00FFEC9E /* NetworkProtectionPixelEvent.swift in Sources */,
11220-
EE0629752B90EE8C00D868B4 /* AccountManagerExtension.swift in Sources */,
1122111211
7BA7CC582AD1203A0042E5CE /* UserText+NetworkProtection.swift in Sources */,
1122211212
7BA7CC4B2AD11EC60042E5CE /* NetworkProtectionControllerErrorStore.swift in Sources */,
1122311213
EE3424612BA0853900173B1B /* VPNUninstaller.swift in Sources */,
@@ -11710,7 +11700,6 @@
1171011700
4B957AB92AC7AE700062CA31 /* SerpHeadersNavigationResponder.swift in Sources */,
1171111701
4B957ABA2AC7AE700062CA31 /* HomePageContinueSetUpModel.swift in Sources */,
1171211702
4B957ABB2AC7AE700062CA31 /* WebKitDownloadTask.swift in Sources */,
11713-
EE0629762B90EE8C00D868B4 /* AccountManagerExtension.swift in Sources */,
1171411703
4B957ABC2AC7AE700062CA31 /* ChromiumLoginReader.swift in Sources */,
1171511704
B6BCC5522AFE4F7D002C5499 /* DataImportTypePicker.swift in Sources */,
1171611705
4B957ABD2AC7AE700062CA31 /* NSAlert+PasswordManager.swift in Sources */,
@@ -12514,7 +12503,6 @@
1251412503
7BE146072A6A83C700C313B8 /* NetworkProtectionDebugMenu.swift in Sources */,
1251512504
B6085D092743AAB600A9C456 /* FireproofDomains.xcdatamodeld in Sources */,
1251612505
85589E8227BBB8630038AD11 /* HomePageView.swift in Sources */,
12517-
EE0629722B90EE8C00D868B4 /* AccountManagerExtension.swift in Sources */,
1251812506
B6BF5D932947199A006742B1 /* SerpHeadersNavigationResponder.swift in Sources */,
1251912507
569277C129DDCBB500B633EF /* HomePageContinueSetUpModel.swift in Sources */,
1252012508
B68D21CF2ACBC9FC002DA3C2 /* ContentBlockerRulesManagerMock.swift in Sources */,

DuckDuckGo/Application/AppDelegate.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, FileDownloadManagerDel
255255
SubscriptionPurchaseEnvironment.currentServiceEnvironment = currentEnvironment
256256

257257
Task {
258-
let accountManager = AccountManager()
258+
let accountManager = AccountManager(subscriptionAppGroup: Bundle.main.appGroup(bundle: .subs))
259259
if let token = accountManager.accessToken {
260260
_ = await SubscriptionService.getSubscription(accessToken: token, cachePolicy: .reloadIgnoringLocalCacheData)
261261
_ = await accountManager.fetchEntitlements(cachePolicy: .reloadIgnoringLocalCacheData)
@@ -567,7 +567,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, FileDownloadManagerDel
567567
func updateSubscriptionStatus() {
568568
#if SUBSCRIPTION
569569
Task {
570-
let accountManager = AccountManager()
570+
let accountManager = AccountManager(subscriptionAppGroup: Bundle.main.appGroup(bundle: .subs))
571571

572572
guard let token = accountManager.accessToken else { return }
573573

DuckDuckGo/Common/Extensions/BundleExtension.swift

+12-11
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,7 @@ extension Bundle {
9595
#endif
9696

9797
func appGroup(bundle: BundleGroup) -> String {
98-
var appGroupName: String
99-
100-
switch bundle {
101-
case .dbp:
102-
appGroupName = "DBP_APP_GROUP"
103-
case .netP:
104-
appGroupName = "NETP_APP_GROUP"
105-
case .subs:
106-
appGroupName = "SUBSCRIPTION_APP_GROUP"
107-
}
108-
98+
let appGroupName = bundle.appGroupKey
10999
guard let appGroup = object(forInfoDictionaryKey: appGroupName) as? String else {
110100
fatalError("Info.plist is missing \(appGroupName)")
111101
}
@@ -131,4 +121,15 @@ enum BundleGroup {
131121
case netP
132122
case dbp
133123
case subs
124+
125+
var appGroupKey: String {
126+
switch self {
127+
case .dbp:
128+
return "DBP_APP_GROUP"
129+
case .netP:
130+
return "NETP_APP_GROUP"
131+
case .subs:
132+
return "SUBSCRIPTION_APP_GROUP"
133+
}
134+
}
134135
}

DuckDuckGo/Common/Utilities/UserDefaultsWrapper.swift

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ extension UserDefaults {
2323
/// The app group's shared UserDefaults
2424
static let netP = UserDefaults(suiteName: Bundle.main.appGroup(bundle: .netP))!
2525
static let dbp = UserDefaults(suiteName: Bundle.main.appGroup(bundle: .dbp))!
26+
static let subs = UserDefaults(suiteName: Bundle.main.appGroup(bundle: .subs))!
2627
}
2728

2829
@propertyWrapper

DuckDuckGo/DBP/DataBrokerProtectionSubscriptionEventHandler.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ final class DataBrokerProtectionSubscriptionEventHandler {
2727
private let authRepository: AuthenticationRepository
2828
private let featureDisabler: DataBrokerProtectionFeatureDisabling
2929

30-
init(accountManager: AccountManaging = AccountManager(),
30+
init(accountManager: AccountManaging = AccountManager(subscriptionAppGroup: Bundle.main.appGroup(bundle: .subs)),
3131
authRepository: AuthenticationRepository = KeychainAuthenticationData(),
3232
featureDisabler: DataBrokerProtectionFeatureDisabling = DataBrokerProtectionFeatureDisabler()) {
3333
self.accountManager = accountManager

DuckDuckGo/DuckDuckGo.entitlements

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
<true/>
1414
<key>com.apple.security.application-groups</key>
1515
<array>
16-
<string>$(NETP_APP_GROUP)</string>
1716
<string>$(DBP_APP_GROUP)</string>
17+
<string>$(NETP_APP_GROUP)</string>
18+
<string>$(SUBSCRIPTION_APP_GROUP)</string>
1819
</array>
1920
<key>com.apple.security.device.audio-input</key>
2021
<true/>

DuckDuckGo/DuckDuckGoAppStore.entitlements

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5+
<key>com.apple.developer.networking.networkextension</key>
6+
<array>
7+
<string>packet-tunnel-provider</string>
8+
<string>app-proxy-provider</string>
9+
</array>
510
<key>com.apple.security.app-sandbox</key>
611
<true/>
712
<key>com.apple.security.application-groups</key>
813
<array>
914
<string>$(DBP_APP_GROUP)</string>
1015
<string>$(NETP_APP_GROUP)</string>
16+
<string>$(SUBSCRIPTION_APP_GROUP)</string>
1117
</array>
1218
<key>com.apple.security.device.audio-input</key>
1319
<true/>
@@ -19,11 +25,6 @@
1925
<true/>
2026
<key>com.apple.security.files.user-selected.read-write</key>
2127
<true/>
22-
<key>com.apple.developer.networking.networkextension</key>
23-
<array>
24-
<string>packet-tunnel-provider</string>
25-
<string>app-proxy-provider</string>
26-
</array>
2728
<key>com.apple.security.network.client</key>
2829
<true/>
2930
<key>com.apple.security.personal-information.location</key>

DuckDuckGo/DuckDuckGoAppStoreCI.entitlements

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
<key>com.apple.security.application-groups</key>
88
<array>
99
<string>$(NETP_APP_GROUP)</string>
10+
<string>$(DBP_APP_GROUP)</string>
11+
<string>$(SUBSCRIPTION_APP_GROUP)</string>
1012
</array>
1113
<key>com.apple.security.device.audio-input</key>
1214
<true/>

DuckDuckGo/DuckDuckGoDebug.entitlements

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
<true/>
1414
<key>com.apple.security.application-groups</key>
1515
<array>
16-
<string>$(NETP_APP_GROUP)</string>
1716
<string>$(DBP_APP_GROUP)</string>
17+
<string>$(NETP_APP_GROUP)</string>
18+
<string>$(SUBSCRIPTION_APP_GROUP)</string>
1819
</array>
1920
<key>com.apple.security.device.audio-input</key>
2021
<true/>

DuckDuckGo/Menus/MainMenuActions.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ extension MainViewController {
725725
/// Clears the PrivacyPro state to make testing easier.
726726
///
727727
private func clearPrivacyProState() {
728-
AccountManager().signOut()
728+
AccountManager(subscriptionAppGroup: Bundle.main.appGroup(bundle: .subs)).signOut()
729729
resetThankYouModalChecks(nil)
730730
UserDefaults.netP.networkProtectionEntitlementsExpired = false
731731

DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift

+9-8
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ final class MoreOptionsMenu: NSMenu {
6262
private let passwordManagerCoordinator: PasswordManagerCoordinating
6363
private let internalUserDecider: InternalUserDecider
6464
private lazy var sharingMenu: NSMenu = SharingMenu(title: UserText.shareMenuItem)
65+
private lazy var accountManager = AccountManager(subscriptionAppGroup: Bundle.main.appGroup(bundle: .subs))
6566

6667
#if NETWORK_PROTECTION
6768
private let networkProtectionFeatureVisibility: NetworkProtectionFeatureVisibility
@@ -317,7 +318,7 @@ final class MoreOptionsMenu: NSMenu {
317318
var items: [NSMenuItem] = []
318319

319320
#if SUBSCRIPTION
320-
if DefaultSubscriptionFeatureAvailability().isFeatureAvailable && !AccountManager().isUserAuthenticated {
321+
if DefaultSubscriptionFeatureAvailability().isFeatureAvailable && !accountManager.isUserAuthenticated {
321322
items.append(contentsOf: makeInactiveSubscriptionItems())
322323
} else {
323324
items.append(contentsOf: makeActiveSubscriptionItems()) // this adds NETP and DBP only if conditionally enabled
@@ -348,11 +349,11 @@ final class MoreOptionsMenu: NSMenu {
348349

349350
items.append(networkProtectionItem)
350351
#if SUBSCRIPTION
351-
if subscriptionFeatureAvailability.isFeatureAvailable && AccountManager().isUserAuthenticated {
352+
if subscriptionFeatureAvailability.isFeatureAvailable && accountManager.isUserAuthenticated {
352353
Task {
353354
let isMenuItemEnabled: Bool
354355

355-
switch await AccountManager().hasEntitlement(for: .networkProtection) {
356+
switch await accountManager.hasEntitlement(for: .networkProtection) {
356357
case let .success(result):
357358
isMenuItemEnabled = result
358359
case .failure:
@@ -381,11 +382,11 @@ final class MoreOptionsMenu: NSMenu {
381382
items.append(dataBrokerProtectionItem)
382383

383384
#if SUBSCRIPTION
384-
if subscriptionFeatureAvailability.isFeatureAvailable && AccountManager().isUserAuthenticated {
385+
if subscriptionFeatureAvailability.isFeatureAvailable && accountManager.isUserAuthenticated {
385386
Task {
386387
let isMenuItemEnabled: Bool
387388

388-
switch await AccountManager().hasEntitlement(for: .dataBrokerProtection) {
389+
switch await accountManager.hasEntitlement(for: .dataBrokerProtection) {
389390
case let .success(result):
390391
isMenuItemEnabled = result
391392
case .failure:
@@ -405,19 +406,19 @@ final class MoreOptionsMenu: NSMenu {
405406
#endif // DBP
406407

407408
#if SUBSCRIPTION
408-
if AccountManager().isUserAuthenticated {
409+
if accountManager.isUserAuthenticated {
409410
let identityTheftRestorationItem = NSMenuItem(title: UserText.identityTheftRestorationOptionsMenuItem,
410411
action: #selector(openIdentityTheftRestoration),
411412
keyEquivalent: "")
412413
.targetting(self)
413414
.withImage(.itrIcon)
414415
items.append(identityTheftRestorationItem)
415416

416-
if subscriptionFeatureAvailability.isFeatureAvailable && AccountManager().isUserAuthenticated {
417+
if subscriptionFeatureAvailability.isFeatureAvailable && accountManager.isUserAuthenticated {
417418
Task {
418419
let isMenuItemEnabled: Bool
419420

420-
switch await AccountManager().hasEntitlement(for: .identityTheftRestoration) {
421+
switch await accountManager.hasEntitlement(for: .identityTheftRestoration) {
421422
case let .success(result):
422423
isMenuItemEnabled = result
423424
case .failure:

DuckDuckGo/NavigationBar/View/NavigationBarViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ final class NavigationBarViewController: NSViewController {
328328

329329
#if SUBSCRIPTION
330330
if DefaultSubscriptionFeatureAvailability().isFeatureAvailable {
331-
let accountManager = AccountManager()
331+
let accountManager = AccountManager(subscriptionAppGroup: Bundle.main.appGroup(bundle: .subs))
332332
let networkProtectionTokenStorage = NetworkProtectionKeychainTokenStore()
333333

334334
if accountManager.accessToken != nil && (try? networkProtectionTokenStorage.fetchToken()) == nil {

DuckDuckGo/NetworkProtection/AppTargets/BothAppTargets/NetworkProtection+ConvenienceInitializers.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ extension NetworkProtectionKeychainTokenStore {
5959

6060
convenience init(isSubscriptionEnabled: Bool) {
6161
#if SUBSCRIPTION
62-
let accessTokenProvider: () -> String? = { AccountManager().accessToken }
62+
let accessTokenProvider: () -> String? = { AccountManager(subscriptionAppGroup: Bundle.main.appGroup(bundle: .subs)).accessToken }
6363
#else
6464
let accessTokenProvider: () -> String? = { return nil }
6565
#endif

DuckDuckGo/NetworkProtection/AppTargets/BothAppTargets/NetworkProtectionAppEvents.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ final class NetworkProtectionAppEvents {
8484
await featureVisibility.disableIfUserHasNoAccess()
8585

8686
#if SUBSCRIPTION
87-
await AccountManager().refreshSubscriptionAndEntitlements()
87+
await AccountManager(subscriptionAppGroup: Bundle.main.appGroup(bundle: .subs)).refreshSubscriptionAndEntitlements()
8888
#endif
8989
}
9090
}

DuckDuckGo/NetworkProtection/AppTargets/BothAppTargets/NetworkProtectionTunnelController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ final class NetworkProtectionTunnelController: TunnelController, TunnelSessionPr
7979
#if SUBSCRIPTION
8080
// MARK: - Subscriptions
8181

82-
private let accountManager = AccountManager()
82+
private let accountManager = AccountManager(subscriptionAppGroup: Bundle.main.appGroup(bundle: .subs))
8383
#endif
8484

8585
// MARK: - Debug Options Support

DuckDuckGo/NetworkProtection/AppTargets/DeveloperIDTarget/NetworkProtectionSubscriptionEventHandler.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ import NetworkProtectionUI
2626

2727
final class NetworkProtectionSubscriptionEventHandler {
2828

29-
private let accountManager: AccountManaging
29+
private let accountManager: AccountManager
3030
private let networkProtectionRedemptionCoordinator: NetworkProtectionCodeRedeeming
3131
private let networkProtectionTokenStorage: NetworkProtectionTokenStore
3232
private let networkProtectionFeatureDisabler: NetworkProtectionFeatureDisabling
3333
private let userDefaults: UserDefaults
3434
private var cancellables = Set<AnyCancellable>()
3535

36-
init(accountManager: AccountManaging = AccountManager(),
36+
init(accountManager: AccountManager = AccountManager(subscriptionAppGroup: Bundle.main.appGroup(bundle: .subs)),
3737
networkProtectionRedemptionCoordinator: NetworkProtectionCodeRedeeming = NetworkProtectionCodeRedemptionCoordinator(),
3838
networkProtectionTokenStorage: NetworkProtectionTokenStore = NetworkProtectionKeychainTokenStore(),
3939
networkProtectionFeatureDisabler: NetworkProtectionFeatureDisabling = NetworkProtectionFeatureDisabler(),
@@ -49,7 +49,7 @@ final class NetworkProtectionSubscriptionEventHandler {
4949

5050
private func subscribeToEntitlementChanges() {
5151
Task {
52-
switch await AccountManager().hasEntitlement(for: .networkProtection) {
52+
switch await accountManager.hasEntitlement(for: .networkProtection) {
5353
case .success(let hasEntitlements):
5454
Task {
5555
await handleEntitlementsChange(hasEntitlements: hasEntitlements)

0 commit comments

Comments
 (0)