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

Subscription oauth v2 #3480

Closed
wants to merge 65 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
cc16889
builds
federicocappelli Oct 16, 2024
8b07ea5
Merge branch 'main' into fcappelli/subscription_oauth_api_v2
federicocappelli Oct 16, 2024
79faa6b
auth and first purchase improved
federicocappelli Oct 21, 2024
44e00ee
Merge branch 'main' into fcappelli/subscription_oauth_api_v2
federicocappelli Oct 21, 2024
c6c2bef
purchase flow fixed
federicocappelli Oct 22, 2024
c640a91
Merge branch 'main' into fcappelli/subscription_oauth_api_v2
federicocappelli Oct 22, 2024
018751a
purchase fixed
federicocappelli Oct 23, 2024
de81314
token fixes
federicocappelli Oct 23, 2024
b4c661e
loggers improved and restore fixed
federicocappelli Oct 24, 2024
d123038
subscription refresh improved
federicocappelli Oct 25, 2024
9d90ccf
v1 to v2 auth migration
federicocappelli Oct 25, 2024
457922c
Merge branch 'main' into fcappelli/subscription_oauth_api_v2
federicocappelli Oct 25, 2024
60d4012
lint ad restore commented code
federicocappelli Oct 25, 2024
07e2cc0
review suggestions applied
federicocappelli Oct 29, 2024
bd5bb1b
tests and logs
federicocappelli Oct 30, 2024
e92d0db
vpn fixed
federicocappelli Oct 31, 2024
1406315
debug menu improved
federicocappelli Oct 31, 2024
eebbc48
unit tests and lint
federicocappelli Oct 31, 2024
8ea3254
unit tests and improvements
federicocappelli Nov 1, 2024
c78a9c2
signout as async
federicocappelli Nov 1, 2024
c021b95
Merge branch 'main' into fcappelli/subscription_oauth_api_v2
federicocappelli Nov 4, 2024
0f426a1
Merge branch 'main' into fcappelli/subscription_oauth_api_v2
federicocappelli Nov 4, 2024
f06370b
lint
federicocappelli Nov 5, 2024
5f69e54
BSK points to branch now
federicocappelli Nov 5, 2024
929e12d
bsk updated
federicocappelli Nov 5, 2024
386fd70
Merge branch 'main' of https://github.com/duckduckgo/iOS into fcappel…
federicocappelli Nov 6, 2024
b018cce
bsk local
federicocappelli Nov 7, 2024
00e55c5
Merge branch 'main' of https://github.com/duckduckgo/iOS into fcappel…
federicocappelli Nov 7, 2024
a955a78
BSK
federicocappelli Nov 7, 2024
b67e5d4
Merge branch 'main' into fcappelli/subscription_oauth_api_v2
federicocappelli Nov 7, 2024
47ac372
BSK update
federicocappelli Nov 8, 2024
80be4fe
Merge branch 'main' into fcappelli/subscription_oauth_api_v2
federicocappelli Nov 14, 2024
bd51e3f
DI improved
federicocappelli Nov 19, 2024
7327d2d
Merge branch 'main' into fcappelli/subscription_oauth_api_v2
federicocappelli Nov 19, 2024
67d5d50
token v1/v2 exchange fixed, token providing improved
federicocappelli Nov 22, 2024
d0c8344
updates after mac integration
federicocappelli Nov 27, 2024
60bad87
Merge branch 'main' into fcappelli/subscription_oauth_api_v2
federicocappelli Nov 27, 2024
170ed9e
merge
federicocappelli Nov 27, 2024
32e5de6
Merge branch 'main' into fcappelli/subscription_oauth_api_v2
federicocappelli Nov 27, 2024
87455ba
local bsk
federicocappelli Nov 27, 2024
0191b02
project fix
federicocappelli Nov 27, 2024
bd5cb7c
unit tests builds
federicocappelli Nov 28, 2024
f229b65
main merge
federicocappelli Nov 29, 2024
e4fbf00
BSK > branch
federicocappelli Nov 29, 2024
f8eabd5
Merge branch 'main' into fcappelli/subscription_oauth_api_v2
federicocappelli Nov 29, 2024
a745b49
packages
federicocappelli Nov 29, 2024
b3482bd
Merge branch 'main' into fcappelli/subscription_oauth_api_v2
federicocappelli Dec 2, 2024
464e598
Merge branch 'main' into fcappelli/subscription_oauth_api_v2
federicocappelli Dec 2, 2024
ba4cbad
Merge branch 'main' into fcappelli/subscription_oauth_api_v2
federicocappelli Dec 12, 2024
edf1bfa
updates from mac and unit tests fixed
federicocappelli Dec 12, 2024
88cd2d9
testing comments fixed
federicocappelli Jan 6, 2025
7b93366
BSK updated
federicocappelli Jan 7, 2025
e4dfc38
Merge branch 'main' into fcappelli/subscription_oauth_api_v2
federicocappelli Jan 8, 2025
0053c73
Merge branch 'main' into fcappelli/subscription_oauth_api_v2
federicocappelli Jan 9, 2025
62bd2da
BSK updated, some flows updated
federicocappelli Jan 10, 2025
b72a122
subscription manager load initial data improved, pixels added
federicocappelli Jan 12, 2025
4e887d4
BSK update with subscription cache bug fix
federicocappelli Jan 13, 2025
6f3a7ad
settings and init improvements
federicocappelli Jan 16, 2025
7a0e848
Merge branch 'main' into fcappelli/subscription_oauth_api_v2
federicocappelli Jan 16, 2025
ef81d09
Subscription stuff renamed
federicocappelli Jan 20, 2025
b4196db
BSK updated
federicocappelli Jan 20, 2025
bc33fcf
Merge branch 'main' into fcappelli/subscription_oauth_api_v2
federicocappelli Jan 20, 2025
5660c74
Merge branch 'main' into fcappelli/subscription_oauth_api_v2
federicocappelli Jan 20, 2025
5f574f3
Merge branch 'main' into fcappelli/subscription_oauth_api_v2
federicocappelli Jan 21, 2025
d045cce
pr suggestions
federicocappelli Jan 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Subscription stuff renamed
  • Loading branch information
federicocappelli committed Jan 20, 2025
commit ef81d0983cf52bb01487520cdd101eb0ec1c973e
32 changes: 32 additions & 0 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,10 @@
F15531922BF215ED0029ED04 /* SubscriptionTestingUtilities in Frameworks */ = {isa = PBXBuildFile; productRef = F15531912BF215ED0029ED04 /* SubscriptionTestingUtilities */; };
F15531942BF215F60029ED04 /* Subscription in Frameworks */ = {isa = PBXBuildFile; productRef = F15531932BF215F60029ED04 /* Subscription */; };
F15531962BF215F60029ED04 /* SubscriptionTestingUtilities in Frameworks */ = {isa = PBXBuildFile; productRef = F15531952BF215F60029ED04 /* SubscriptionTestingUtilities */; };
F15764C02D3E6AE60086AA21 /* Networking in Frameworks */ = {isa = PBXBuildFile; productRef = F15764BF2D3E6AE60086AA21 /* Networking */; };
F15764C22D3E6AF60086AA21 /* Networking in Frameworks */ = {isa = PBXBuildFile; productRef = F15764C12D3E6AF60086AA21 /* Networking */; };
F15764C42D3E6AF60086AA21 /* NetworkingTestingUtils in Frameworks */ = {isa = PBXBuildFile; productRef = F15764C32D3E6AF60086AA21 /* NetworkingTestingUtils */; };
F15764C62D3E6B010086AA21 /* Networking in Frameworks */ = {isa = PBXBuildFile; productRef = F15764C52D3E6B010086AA21 /* Networking */; };
F15D43201E706CC500BF2CDC /* AutocompleteViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F15D431F1E706CC500BF2CDC /* AutocompleteViewController.swift */; };
F1617C131E572E0300DEDCAF /* TabSwitcherViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1617C121E572E0300DEDCAF /* TabSwitcherViewController.swift */; };
F1617C151E57336D00DEDCAF /* TabManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1617C141E57336D00DEDCAF /* TabManager.swift */; };
Expand Down Expand Up @@ -3294,6 +3298,7 @@
F1B3DEC12D2D90BB00D33FA5 /* NetworkingTestingUtils in Frameworks */,
F1AFDF822D2EE1D100DB313F /* PersistenceTestingUtils in Frameworks */,
EEFAB4672A73C230008A38E4 /* NetworkProtectionTestUtils in Frameworks */,
F15764C02D3E6AE60086AA21 /* Networking in Frameworks */,
4BE67B072B96B9B0007335F7 /* Common in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -3328,6 +3333,8 @@
4BE67B012B96B741007335F7 /* Common in Frameworks */,
F15531962BF215F60029ED04 /* SubscriptionTestingUtilities in Frameworks */,
F15531942BF215F60029ED04 /* Subscription in Frameworks */,
F15764C42D3E6AF60086AA21 /* NetworkingTestingUtils in Frameworks */,
F15764C22D3E6AF60086AA21 /* Networking in Frameworks */,
4BE67B032B96B864007335F7 /* ContentBlocking in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -3359,6 +3366,7 @@
98424A962CED4F430071C7DB /* OHHTTPStubs in Frameworks */,
98424A972CED4F430071C7DB /* OHHTTPStubsSwift in Frameworks */,
98424A982CED4F430071C7DB /* ContentBlocking in Frameworks */,
F15764C62D3E6B010086AA21 /* Networking in Frameworks */,
98424AB22CEDD6150071C7DB /* BrowserServicesKit in Frameworks */,
98424A992CED4F430071C7DB /* SubscriptionTestingUtilities in Frameworks */,
98424A9A2CED4F430071C7DB /* Subscription in Frameworks */,
Expand Down Expand Up @@ -7073,6 +7081,7 @@
F15531912BF215ED0029ED04 /* SubscriptionTestingUtilities */,
F1B3DEC02D2D90BB00D33FA5 /* NetworkingTestingUtils */,
F1AFDF812D2EE1D100DB313F /* PersistenceTestingUtils */,
F15764BF2D3E6AE60086AA21 /* Networking */,
);
productName = DuckDuckGoTests;
productReference = 84E341A61E2F7EFB00BDBA6F /* UnitTests.xctest */;
Expand Down Expand Up @@ -7138,6 +7147,8 @@
4BE67B022B96B864007335F7 /* ContentBlocking */,
F15531932BF215F60029ED04 /* Subscription */,
F15531952BF215F60029ED04 /* SubscriptionTestingUtilities */,
F15764C12D3E6AF60086AA21 /* Networking */,
F15764C32D3E6AF60086AA21 /* NetworkingTestingUtils */,
);
productName = IntegrationTests;
productReference = 85D33FCB25C97B6E002B91A6 /* IntegrationTests.xctest */;
Expand Down Expand Up @@ -7210,6 +7221,7 @@
98424AB32CEDD61C0071C7DB /* BrowserServicesKitTestsUtils */,
F1B3DEC22D2D90D500D33FA5 /* NetworkingTestingUtils */,
F1AFDF7F2D2EE10A00DB313F /* PersistenceTestingUtils */,
F15764C52D3E6B010086AA21 /* Networking */,
);
productName = DuckDuckGoTests;
productReference = 98424AA92CED4F430071C7DB /* WebViewUnitTests.xctest */;
Expand Down Expand Up @@ -12304,6 +12316,26 @@
package = 98A16C2928A11BDE00A6C003 /* XCRemoteSwiftPackageReference "BrowserServicesKit" */;
productName = SubscriptionTestingUtilities;
};
F15764BF2D3E6AE60086AA21 /* Networking */ = {
isa = XCSwiftPackageProductDependency;
package = 98A16C2928A11BDE00A6C003 /* XCRemoteSwiftPackageReference "BrowserServicesKit" */;
productName = Networking;
};
F15764C12D3E6AF60086AA21 /* Networking */ = {
isa = XCSwiftPackageProductDependency;
package = 98A16C2928A11BDE00A6C003 /* XCRemoteSwiftPackageReference "BrowserServicesKit" */;
productName = Networking;
};
F15764C32D3E6AF60086AA21 /* NetworkingTestingUtils */ = {
isa = XCSwiftPackageProductDependency;
package = 98A16C2928A11BDE00A6C003 /* XCRemoteSwiftPackageReference "BrowserServicesKit" */;
productName = NetworkingTestingUtils;
};
F15764C52D3E6B010086AA21 /* Networking */ = {
isa = XCSwiftPackageProductDependency;
package = 98A16C2928A11BDE00A6C003 /* XCRemoteSwiftPackageReference "BrowserServicesKit" */;
productName = Networking;
};
F1AFDF7F2D2EE10A00DB313F /* PersistenceTestingUtils */ = {
isa = XCSwiftPackageProductDependency;
package = 98A16C2928A11BDE00A6C003 /* XCRemoteSwiftPackageReference "BrowserServicesKit" */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@
"location" : "https://github.com/DuckDuckGo/BrowserServicesKit",
"state" : {
"branch" : "fcappelli/subscription_oauth_api_v2",
"revision" : "c51c7b960e047f6903daf4dadc09a8fe49648f01"
"revision" : "8bed092b8ca59d0d947b4a5b4da6daf2386cf3d5"
}
},
{
"identity" : "content-scope-scripts",
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/content-scope-scripts",
"state" : {
"revision" : "0502ed7de4130bd8705daebaca9aeb20d3e62d15",
"version" : "7.5.0"
"revision" : "7958ddab724c26326333cae13fe81478290607fa",
"version" : "7.6.0"
}
},
{
Expand Down Expand Up @@ -203,8 +203,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/sync_crypto",
"state" : {
"revision" : "0c8bf3c0e75591bc366407b9d7a73a9fcfc7736f",
"version" : "0.3.0"
"revision" : "cc726cebb67367466bc31ced4784e16d44ac68d1",
"version" : "0.4.0"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/AppLifecycle/AppStates/Active.swift
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ struct Active: AppState {
@MainActor
func presentNetworkProtectionStatusSettingsModal() {
Task {
if await AppDependencyProvider.shared.subscriptionManager.isFeatureActive(.networkProtection) {
if await AppDependencyProvider.shared.subscriptionManager.isFeatureAvailableForUser(.networkProtection) {
Task { @MainActor in
(window.rootViewController as? MainViewController)?.segueToVPN()
}
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/AppServices/UNService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ extension UNService: UNUserNotificationCenterDelegate {

private func presentNetworkProtectionStatusSettingsModal() {
Task {
if await AppDependencyProvider.shared.subscriptionManager.isFeatureActive(.networkProtection) {
if await AppDependencyProvider.shared.subscriptionManager.isFeatureAvailableForUser(.networkProtection) {
Task { @MainActor in
(window.rootViewController as? MainViewController)?.segueToVPN()
}
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/AppShortcuts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extension UIApplication {

func refreshVPNShortcuts(vpnFeatureVisibility: DefaultNetworkProtectionVisibility, subscriptionManager: any SubscriptionManager) async {
guard vpnFeatureVisibility.shouldShowVPNShortcut(),
await AppDependencyProvider.shared.subscriptionManager.isFeatureActive(.networkProtection)
await AppDependencyProvider.shared.subscriptionManager.isFeatureAvailableForUser(.networkProtection)
else {
shortcutItems = nil
return
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Feedback/VPNMetadataCollector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ final class DefaultVPNMetadataCollector: VPNMetadataCollector {
func collectPrivacyProInfo() async -> VPNMetadata.PrivacyProInfo {
return .init(
hasPrivacyProAccount: subscriptionManager.isUserAuthenticated,
hasVPNEntitlement: await subscriptionManager.isFeatureActive(.networkProtection)
hasVPNEntitlement: await subscriptionManager.isFeatureAvailableForUser(.networkProtection)
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions DuckDuckGo/OldAppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ final class OldAppDelegate: NSObject, UIApplicationDelegate, DDGApp {
return
}

if await AppDependencyProvider.shared.subscriptionManager.isFeatureActive(.networkProtection) {
if await AppDependencyProvider.shared.subscriptionManager.isFeatureAvailableForUser(.networkProtection) {
let items = [
UIApplicationShortcutItem(type: AppDelegate.ShortcutKey.openVPNSettings,
localizedTitle: UserText.netPOpenVPNQuickAction,
Expand Down Expand Up @@ -1234,7 +1234,7 @@ extension OldAppDelegate: UNUserNotificationCenterDelegate {

func presentNetworkProtectionStatusSettingsModal() {
Task {
if await AppDependencyProvider.shared.subscriptionManager.isFeatureActive(.networkProtection) {
if await AppDependencyProvider.shared.subscriptionManager.isFeatureAvailableForUser(.networkProtection) {
Task { @MainActor in
(window?.rootViewController as? MainViewController)?.segueToVPN()
}
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/SettingsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ extension SettingsViewModel {
state.subscription.hasActiveSubscription = subscription.isActive
let features = await subscriptionManager.currentSubscriptionFeatures(forceRefresh: false)
state.subscription.entitlements = features.compactMap({ feature in
if feature.enabled {
if feature.availableForUser {
return feature.entitlement
} else {
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,14 @@ final class UnifiedFeedbackFormViewModel: ObservableObject {
let itrFeature = features.first { $0.entitlement == .identityTheftRestoration }
let itrgFeature = features.first { $0.entitlement == .identityTheftRestorationGlobal }

if vpnFeature?.enabled ?? false {
if vpnFeature?.availableForUser ?? false {
availableCategories.append(.vpn)
}
if dbpFeature?.enabled ?? false {
if dbpFeature?.availableForUser ?? false {
availableCategories.append(.pir)
}
let idpEnabled = itrFeature?.enabled ?? false
let idpgEnabled = itrgFeature?.enabled ?? false
let idpEnabled = itrFeature?.availableForUser ?? false
let idpgEnabled = itrgFeature?.availableForUser ?? false
if idpEnabled || idpgEnabled {
availableCategories.append(.itr)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ final class NetworkProtectionPacketTunnelProvider: PacketTunnelProvider {

let entitlementsCheck: (() async -> Result<Bool, Error>) = {
Logger.networkProtection.log("Subscription Entitlements check...")
let isNetworkProtectionEnabled = await subscriptionManager.isFeatureActive(.networkProtection)
let isNetworkProtectionEnabled = await subscriptionManager.isFeatureAvailableForUser(.networkProtection)
Logger.networkProtection.log("NetworkProtectionEnabled if: \( isNetworkProtectionEnabled ? "Enabled" : "Disabled", privacy: .public)")
return .success(isNetworkProtectionEnabled)
}
Expand Down